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).

  1. Follow the instructions from Adobe Analytics for mobile apps
  2. Add the AEPAnalytics iOS SDK to your project
// AppDelegate.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 elsereturn }
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])
}