---
title: Set up Product Analytics data capture - Android
description: Access to acquisition analysis and lifetime metrics by implementing the Product Analytics data capture using the CSQ SDK
lastUpdated: 12 February 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/set-up-product-analytics-data-capture/
  md: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/set-up-product-analytics-data-capture/index.md
---

This page instructs how to set up Product Analytics data capture in combination with Experience Analytics.

1. Initialize the Product Analytics configuration with your environment ID.

   * Kotlin

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ


     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()


         CSQ.configureProductAnalytics(
           context = this,
           envId = "YOUR_ENVIRONMENT_ID"
         )


         CSQ.start()
       }
     }
     ```

   * Java

     ```java
     import android.app.Application;
     import com.contentsquare.CSQ;


     public class MyApplication extends Application {
       @Override
       public void onCreate() {
         super.onCreate();


         CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID");


         CSQ.start();
       }
     }
     ```

   Find your environment ID

   `YOUR_ENVIRONMENT_ID` is either provided to you by Contentsquare or you can find it in **Account** > **Manage** > **Projects** > \[Select your project] > **Environments** within the [Product Analytics web app ↗](https://heapanalytics.com/app/).

2. Add the Android View Autocapture Plugin to instrument your app code:

   * Kotlin

     ```kotlin
     plugins {
       // ...


       id("io.heap.gradle") version "1.1.0"
     }
     ```

   * Groovy

     ```groovy
     plugins {
       // ...


       id 'io.heap.gradle' version '1.1.0'
     }
     ```

3. Set up autocapture by adding `enableViewAutocapture = true`.

   * Kotlin

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ


     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()


         CSQ.configureProductAnalytics(
           context = this,
           envId = "YOUR_ENVIRONMENT_ID",
           options = ProductAnalyticsOptions(
             enableViewAutocapture = true
           )
         )


         CSQ.start()
       }
     }
     ```

   * Java

     ```java
     import android.app.Application;
     import com.contentsquare.CSQ;


     public class MyApplication extends Application {
       @Override
       public void onCreate() {
         super.onCreate();


         ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder()
           .enableViewAutocapture(true)
           .build();


         CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);


         CSQ.start();
       }
     }
     ```

4. (Optional) For Jetpack Compose, add the dedicated import and register the Compose Autocapture SDK.

   * Kotlin

     ```kotlin
     dependencies {
       implementation("com.contentsquare.android:sdk:1.5.1")
       implementation("com.contentsquare.android:sdk-compose:1.5.1")
     }
     ```

   * Groovy

     ```groovy
     dependencies {
       implementation 'com.contentsquare.android:sdk:1.5.1'
       implementation 'com.contentsquare.android:sdk-compose:1.5.1'
     }
     ```

   - Kotlin

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ
     import io.heap.autocapture.compose.ComposeAutocaptureSDK


     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()


         ComposeAutocaptureSDK.register()


         CSQ.configureProductAnalytics(
           context = this,
           envId = "YOUR_ENVIRONMENT_ID",
           options = ProductAnalyticsOptions(
             enableViewAutocapture = true
           )
         )


         CSQ.start()
       }
     }
     ```

   - Java

     ```java
     import android.app.Application;
     import com.contentsquare.CSQ;
     import io.heap.autocapture.compose.ComposeAutocaptureSDK;


     public class MyApplication extends Application {
       @Override
       public void onCreate() {
         super.onCreate();


         ComposeAutocaptureSDK.register();


         ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder()
           .enableViewAutocapture(true)
           .build();


         CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);


         CSQ.start();
       }
     }
     ```

5. (Optional) If your Product Analytics environment is hosted in the EU, set the `baseUri` option to `https://mh.ba.contentsquare.net`.

   * Kotlin

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ


     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()


         CSQ.configureProductAnalytics(
           context = this,
           envId = "YOUR_ENVIRONMENT_ID",
           options = ProductAnalyticsOptions(
             enableViewAutocapture = true,
             baseUri = URI("https://mh.ba.contentsquare.net")
           )
         )
       }
     }
     ```

   * Java

     ```java
     import android.app.Application;
     import com.contentsquare.CSQ;


     public class MyApplication extends Application {
       @Override
       public void onCreate() {
         super.onCreate();


         ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder()
             .enableViewAutocapture(true)
             .baseUri(URI.create("https://mh.ba.contentsquare.net"))
             .build();


         CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);
       }
     }
     ```

6. Add the `resumePreviousSession: true` and `disablePageviewAutocapture: true` options to the configuration.

   * Kotlin

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ


     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()


         CSQ.configureProductAnalytics(
           context = this,
           envId = "YOUR_ENVIRONMENT_ID",
           options = ProductAnalyticsOptions(
             enableViewAutocapture = true,
             resumePreviousSession = true,
             disablePageviewAutocapture = true
           )
         )


         CSQ.start()
       }
     }
     ```

   * Java

     ```java
     import android.app.Application;
     import com.contentsquare.CSQ;


     public class MyApplication extends Application {
       @Override
       public void onCreate() {
         super.onCreate();


         ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder()
           .enableViewAutocapture(true)
           .resumePreviousSession(true)
           .disablePageviewAutocapture(true)
           .build();


         CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);


         CSQ.start();
       }
     }
     ```

Note

After adding Product Analytics to your implementation, you may observe a change in the number of sessions collected due to a change of the session timeout definition:

* (previously) Session would timeout 30 minutes after app is in background
* (now) Session would timeout 30 minutes after last event

This is part of our strategy to have a behavior that is more aligned with market standards and web definition.
