Use Adobe Analytics
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, Zoning Analysis, Session Replay).
Prerequisites
Section titled Prerequisites- Follow the instructions from Adobe Analytics for mobile apps
- Add the AEPAnalytics iOS SDK to your project
Code implementation
Section titled Code implementationfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // ... your existing code .. MobileCore.registerExtensions([Identity.self, Analytics.self, ....], { // ... your existing code ..
self.sendCSMatchingKeyIfNeeded() }) // ... your existing code ..}
func sendCSMatchingKeyIfNeeded() { 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)"
Contentsquare.send(dynamicVar: DynamicVar(key: csMatchingKey, value: csMatchingKeyValue)) MobileCore.track(state: "csMatchingKey_state", data: [csMatchingKey: csMatchingKeyValue])}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ... your existing code .. [AEPMobileCore registerExtensions:@[AEPMobileEdgeIdentity.class, AEPMobileAnalytics.class] completion:^{ // ... your existing code ..
[self sendCSMatchingKeyIfNeeded]; }];
// ... your existing code ..}
- (void)sendCSMatchingKeyIfNeeded { 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}];}