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 PrerequisitesAdobe SDK code requirements
Make sure you register at least Identity.EXTENSION
and Analytics.EXTENSION
extensions before starting MobileCore
.
Check the Adobe iOS AEPAnalytics SDK ↗ repository for that.
- Follow the instructions from Adobe Analytics for mobile apps ↗
- Add the AEPAnalytics iOS SDK ↗ to your project
Code implementation
Section titled Code implementationAdd the CSAppLifecycleObserver to the ProcessLifecycleOwner ↗
public class CSAppLifecycleObserver implements DefaultLifecycleObserver { private final SharedPreferences sharedPreferences; private final Random random = new Random();
public CSAppLifecycleObserver(@NonNull Context appContext) { sharedPreferences = appContext.getSharedPreferences( "CSAppLifecycleObserver", MODE_PRIVATE ); }
@Override public void onResume(@NonNull LifecycleOwner owner) { DefaultLifecycleObserver.super.onResume(owner); sendCSMatchingKeyIfNeeded(); }
public void sendCSMatchingKeyIfNeeded() { String csMatchingKeyTimestampKey = "csMatchingKey_ts"; int csMatchingKeyValidityMs = 1800000; // 30 minutes
long currentTimestamp = new Date().getTime(); long csMatchingKeyIsPreviousTimestamp = sharedPreferences.getLong(csMatchingKeyTimestampKey, 0);
if ((currentTimestamp - csMatchingKeyIsPreviousTimestamp) <= csMatchingKeyValidityMs) { return; }
sharedPreferences.edit().putLong(csMatchingKeyTimestampKey, currentTimestamp).apply();
String csMatchingKey = "csMatchingKey"; String csMatchingKeyValue = random.nextDouble() + "_" + currentTimestamp;
Contentsquare.send(csMatchingKey, csMatchingKeyValue); MobileCore.trackState(csMatchingKey + "_state", Collections.singletonMap(csMatchingKey, csMatchingKeyValue)); }}
class CSAppLifecycleObserver(appContext: Context) : DefaultLifecycleObserver { private val sharedPreferences = appContext.getSharedPreferences( "CSAppLifecycleObserver", Context.MODE_PRIVATE ) private val random = Random()
override fun onResume(owner: LifecycleOwner) { super.onResume(owner) sendCSMatchingKeyIfNeeded() }
private fun sendCSMatchingKeyIfNeeded() { val csMatchingKeyTimestampKey = "csMatchingKey_ts" val csMatchingKeyValidityMs = 1800000 // 30 minutes
val currentTimestamp = Date().time val csMatchingKeyIsPreviousTimestamp = sharedPreferences.getLong(csMatchingKeyTimestampKey, 0)
if (currentTimestamp - csMatchingKeyIsPreviousTimestamp <= csMatchingKeyValidityMs) { return }</TabItem></Tabs> sharedPreferences.edit().putLong(csMatchingKeyTimestampKey, currentTimestamp).apply()
val csMatchingKey = "csMatchingKey" val csMatchingKeyValue = random.nextDouble().toString() + "_" + currentTimestamp
Contentsquare.send(csMatchingKey, csMatchingKeyValue) MobileCore.trackState("${csMatchingKey}_state", Collections.singletonMap(csMatchingKey, csMatchingKeyValue)) }}