---
title: Getting Started with Product Analytics - Android
description: Integrate the CSQ SDK for Product Analytics into your Android app in minutes
lastUpdated: 11 March 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/
  md: https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/index.md
---

This quick start guide shows you how to get Contentsquare Product Analytics set up in an Android application.

Once you've completed the setup process, the Contentsquare SDK will capture a wide variety of user interactions in your application with no additional code required.

Upgrading

See our guides to upgrade to the CSQ SDK from the [Heap Core SDK](../product-analytics/upgrade-from-heap-core-sdk/) or the [Heap Classic SDK](../product-analytics/upgrade-from-heap-classic-sdk/).

## Install the SDK

1. In your app-level `build.gradle` file, add the dependency for the CSQ SDK and the CSQ Compose SDK.

   * Kotlin

     **build.gradle.kts**

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

   * Groovy

     **build.gradle**

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

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

   * Kotlin

     **build.gradle.kts**

     ```kotlin
     plugins {
       // ...


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

   * Groovy

     **build.gradle**

     ```groovy
     plugins {
       // ...


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

3. Once the dependencies and plugins have been added, sync Gradle and rebuild your application.

## Start the SDK

1. Add your Product Analytics Environment ID using `CSQ.configureProductAnalytics()`.

   * Kotlin

     **MyApplication.kt**

     ```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"
         )
       }
     }
     ```

   * Java

     **MyApplication.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");
       }
     }
     ```

   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. Recommended To capture automatically screenviews and interactions, enable autocapture by setting `enableViewAutocapture` to `true`.

   * Kotlin

     **MyApplication.kt**

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

   * Java

     **MyApplication.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);
       }
     }
     ```

3. (Optional) For Jetpack Compose, register the Compose Autocapture SDK.

   * Kotlin

     **MyApplication.kt**

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

   * Java

     **MyApplication.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);
       }
     }
     ```

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

   * Kotlin

     **MyApplication.kt**

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

     **MyApplication.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);
       }
     }
     ```

5. Add a call to `CSQ.start(this)` within `onCreate()` of a custom Application subclass:

   * Kotlin

     **MyApplication.kt**

     ```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(this)
       }
     }
     ```

   * Java

     **MyApplication.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(this);
       }
     }
     ```

6. Start your application, and check logs for this output:

   ```text
   [INFO] CSQ 1.5.1 is attempting to start Product Analytics.
   ```

## Get user consent

The CSQ SDK treats users as opted-out by default.

Implement the [`optIn()`](command-reference/#csqoptin) API to forward user consent to the SDK and generate a user ID.

* Kotlin

  ```kotlin
  CSQ.start(context)
  // ...
  val optinButton: Button = ...
  optinButton.setOnClickListener {
      CSQ.optIn(it.context)
      // Then finish initialization and move to the next screen...
  }
  ```

* Java

  ```java
  CSQ.start(context);
  // ...
  Button optinButton = ...
  optinButton.setOnClickListener(view -> {
      CSQ.optIn(view.getContext());
      // Then finish initialization and move to the next screen...
  });
  ```

Once tracking has started, you’re able to take full advantage of the CSQ SDK API to identify users, track custom events, and more.

Contentsquare's Product Analytics module will also automatically start tracking a wide range of user interactions, view controller changes, and app version changes without any additional code.

## Next steps

Our SDK offers a wide range of features to enhance your implementation, including extended tracking capabilities, and personal data masking.

[Track identity ](track-identity/)Link anonymous and identified user data across sessions and devices for comprehensive analytics

[Track push notifications ](track-push-notifications/)Track mobile notification interactions automatically

[Track events manually ](track-events-manually/)Learn how to track custom events

[Hide sensitive data ](hide-sensitive-data/)Protect sensitive data by disabling text capture, masking specific views, or ignoring interactions

Session Replay and Error Monitoring are both available with the [Experience Analytics Extension](dxae-setup/), which you can purchase separately.

[Set up the Experience Analytics extension](dxae-setup/)
