Product Analytics data capture
This page instructs how to set up Product Analytics data capture in combination with Experience Analytics.
-
Initialize the SDK with your environment ID.
- Product Analytics
- Experience Platform
Get Early Access to CSQ Experience Platform, our latest, all-in-one offering.
Reach out to your Customer Success Manager to join the Early Access Program.
MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID"))}}MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID"))}} -
Apply the Contentsquare Gradle plugin to your Android application module to instrument your app code. If the root build file declares plugin versions with
apply false, declare the version there and apply the plugin in the application module without repeating the version.The Contentsquare Gradle plugin requires Android Gradle Plugin (AGP) 8.1 or later.
build.gradle.kts plugins {// ...id("com.contentsquare.gradle") version "1.1.0"}build.gradle plugins {// ...id 'com.contentsquare.gradle' version "1.1.0"}When upgrading from
io.heap.gradleorcom.contentsquare.error.analysis.network, remove the old plugin declaration. The Contentsquare Gradle plugin replaces both, and the build fails if one of them is applied to the same module. -
Set up autocapture by adding
enableViewAutocapture = true. With this option,CSQ.start()registers both Views and Jetpack Compose autocapture.- Product Analytics
- Experience Platform
Get Early Access to CSQ Experience Platform, our latest, all-in-one offering.
Reach out to your Customer Success Manager to join the Early Access Program.
MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID",options = AnalyticsOptions(enableViewAutocapture = true)))}}MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID",options = AnalyticsOptions(enableViewAutocapture = true)))}} -
For Jetpack Compose, add the
sdk-composedependency.build.gradle.kts dependencies {implementation("com.contentsquare.android:sdk:1.13.0")implementation("com.contentsquare.android:sdk-compose:1.13.0")}build.gradle dependencies {implementation 'com.contentsquare.android:sdk:1.13.0'implementation 'com.contentsquare.android:sdk-compose:1.13.0'} -
(Optional) If your Product Analytics environment is hosted in the EU, set the
baseUrioption tohttps://mh.ba.contentsquare.net.- Product Analytics
- Experience Platform
Get Early Access to CSQ Experience Platform, our latest, all-in-one offering.
Reach out to your Customer Success Manager to join the Early Access Program.
MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID",options = AnalyticsOptions(enableViewAutocapture = true,baseUri = URI.create("https://mh.ba.contentsquare.net"))))}}MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID",options = AnalyticsOptions(enableViewAutocapture = true,baseUri = URI.create("https://mh.ba.contentsquare.net"))))}} -
Add
disablePageviewAutocapture = trueto prevent automatic screenviews and keep tracking screens withCSQ.trackScreenview(). Interaction autocapture stays on, but interactions have no automatic screenview to attach to. See the screenview options.- Product Analytics
- Experience Platform
Get Early Access to CSQ Experience Platform, our latest, all-in-one offering.
Reach out to your Customer Success Manager to join the Early Access Program.
MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID",options = AnalyticsOptions(enableViewAutocapture = true,disablePageviewAutocapture = true)))}}MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID",options = AnalyticsOptions(enableViewAutocapture = true,disablePageviewAutocapture = true)))}}

