---
title: Use Adobe Analytics - Android
description: Leverage our native integration to use Adobe Analytics segments in Contentsquare
lastUpdated: 09 October 2025
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/adobe-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-android/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

**Adobe SDK code requirements**

Make sure you register at least `Identity.EXTENSION` and `Analytics.EXTENSION` extensions before starting `MobileCore`. Check the [Getting Started with Adobe Analytics Android Extension ↗](https://github.com/adobe/aepsdk-analytics-android/blob/main/Documentation/getting-started.md) repository for that.

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

## Code implementation

Add the CSAppLifecycleObserver to the [ProcessLifecycleOwner ↗](https://developer.android.com/reference/androidx/lifecycle/ProcessLifecycleOwner)

Note

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

- Kotlin

  ```kotlin
  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
          }


          sharedPreferences.edit().putLong(csMatchingKeyTimestampKey, currentTimestamp).apply()


          val csMatchingKey = "csMatchingKey"
          val csMatchingKeyValue = random.nextDouble().toString() + "_" + currentTimestamp


          CSQ.addDynamicVar(csMatchingKey, csMatchingKeyValue)
          MobileCore.trackState("${csMatchingKey}_state", Collections.singletonMap(csMatchingKey, csMatchingKeyValue))
      }
  }
  ```

- Java

  ```java
  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;


          CSQ.addDynamicVar(csMatchingKey, csMatchingKeyValue);
          MobileCore.trackState(csMatchingKey + "_state", Collections.singletonMap(csMatchingKey, csMatchingKeyValue));
      }
  }
  ```
