---
title: Adobe Analytics - iOS
description: Leverage our native integration to use Adobe Analytics segments in Contentsquare, with the CSQ iOS SDK
lastUpdated: 09 October 2025
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/adobe-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/adobe-analytics/index.md
---

Analyze your data from anywhere in the customer journey using your Adobe Analytics segments.\
Contentsquare allows you to use your Adobe Analytics segments in every Contentsquare feature (Journey Analysis, Page Comparator, Session Replay).

Warning

Sessions without at least one screenview will be discarded.\
You should implement your screen tracking plan first, to have your Adobe Analytics integration work.\
See [Track screens](../track-screens/).

## Prerequisites

1. Follow the instructions from [Adobe Analytics for mobile apps ↗](https://support.contentsquare.com/hc/en-us/articles/37271665881745)
2. Add the [AEPAnalytics iOS SDK ↗](https://github.com/adobe/aepsdk-analytics-ios) to your project

## Code implementation

Note

**Adobe SDK code requirements**

* Make sure you register at least `AEPIdentity` and `AEPAnalytics` extensions before starting `AEPCore`. Check the [Getting Started with Adobe Analytics iOS Extension ↗](https://github.com/adobe/aepsdk-analytics-ios/blob/main/Documentation/AEPAnalytics.md) repository for that.

**Why 30 minutes before sending a new csMatchingKey**

* 30 minutes is Contentsquare default session duration.
* Setting a value **higher** than 30 minutes would cause overlapping on our sessions, and would impact negatively the data import from Adobe.
* Setting a value **lower** than 30 minutes would make you to send more data to Adobe.\
  This could cause the variable to reach Adobe's threshold, causing Adobe to filter values, and potentially impact your billing.\
  See [Low-traffic value in Adobe Analytics ↗](https://experienceleague.adobe.com/docs/analytics/technotes/low-traffic.html)

- Swift

  ```swift
  var canSendCSMatchingKey = false


  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      // ... your existing code ..
      MobileCore.registerExtensions([Identity.self, Analytics.self, ....], {
          // ... your existing code ..


          self.canSendCSMatchingKey = true
          self.sendCSMatchingKeyIfNeeded()
      })


      // When going back to foreground, more than 30 minutes may have elapsed.
      // In this situation Contentsquare SDK may create a new session
      // This is why `sendCSMatchingKeyIfNeeded` must be called in this situation
      NotificationCenter.default.addObserver(self,
                                             selector: #selector(sendCSMatchingKeyIfNeeded),
                                             name: UIApplication.didBecomeActiveNotification,
                                             object: nil)


      // ... your existing code ..
  }


  @objc
  func sendCSMatchingKeyIfNeeded() {
    guard canSendCSMatchingKey else { return }


    let csMatchingKeyTimestampKey = "csMatchingKey_ts"
    let csMatchingKeyValidityMs = 1_800_000 // 30 minutes


    let currentTimestamp = Int(Date().timeIntervalSince1970 * 1000)
    let csMatchingKeyIsPreviousTimestamp = UserDefaults.standard.integer(forKey: csMatchingKeyTimestampKey)


    guard (currentTimestamp - csMatchingKeyIsPreviousTimestamp) > csMatchingKeyValidityMs else {
      return
    }


    UserDefaults.standard.set(currentTimestamp, forKey: csMatchingKeyTimestampKey)


    let csMatchingKey = "csMatchingKey"
    let csMatchingKeyValue = "\(Double.random(in: 0..<1))_\(currentTimestamp)"


    CSQ.addDynamicVar(dynamicVar: DynamicVar(key: csMatchingKey, value: csMatchingKeyValue))
    MobileCore.track(state: "csMatchingKey_state", data: [csMatchingKey: csMatchingKeyValue])
  }
  ```

- Objective-C

  ```objective-c
  @interface AppDelegate ()


  @property (nonatomic, assign) BOOL canSendCSMatchingKey;


  @end


  @implementation AppDelegate


  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      self.canSendCSMatchingKey = NO;


      // ... your existing code ..
      [AEPMobileCore registerExtensions:@[AEPMobileEdgeIdentity.class, AEPMobileAnalytics.class] completion:^{
          // ... your existing code ..


          self.canSendCSMatchingKey = YES;
          [self sendCSMatchingKeyIfNeeded];
      }];


      // When going back to foreground, more than 30 minutes may have elapsed.
      // In this situation Contentsquare SDK may create a new session
      // This is why `sendCSMatchingKeyIfNeeded` must be called in this situation
      [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(sendKeyIfNeeded)
                                                  name:UIApplicationDidBecomeActiveNotification
                                                object:nil];


      // ... your existing code ..
      return YES;
  }


  - (void)sendCSMatchingKeyIfNeeded {
      if (!self.canSendCSMatchingKey) {
        return;
      }


      NSString *csMatchingKeyTimestampKey = @"csMatchingKey_ts";
      NSInteger csMatchingKeyValidityMs = 1800000; // 30 minutes


      NSInteger currentTimestamp = (NSInteger)([[NSDate date] timeIntervalSince1970] * 1000);
      NSInteger csMatchingKeyIsPreviousTimestamp = [[NSUserDefaults standardUserDefaults] integerForKey:csMatchingKeyTimestampKey];


      if ((currentTimestamp - csMatchingKeyIsPreviousTimestamp) <= csMatchingKeyValidityMs) {
          return;
      }


      [[NSUserDefaults standardUserDefaults] setInteger:currentTimestamp forKey:csMatchingKeyTimestampKey];


      NSString *csMatchingKey = @"csMatchingKey";
      NSString *csMatchingKeyValue = [NSString stringWithFormat:@"%f_%f", (double)arc4random() / UINT32_MAX, currentTimestamp];


      DynamicVar *csMatchingKeyDynamicVar = [[DynamicVar alloc] initWithKey:csMatchingKey
                                                        stringValue:csMatchingKeyValue
                                                              error:(NSError * _Nullable __autoreleasing * _Nullable)];
      [Contentsquare sendWithDynamicVar:csMatchingKeyDynamicVar];
      [AEPMobileCore trackState:@"csMatchingKey_state" data:@{csMatchingKey:csMatchingKeyValue}];
  }


  @end
  ```
