Getting Started with Product Analytics
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.
Install the SDK
Section titled Install the SDK-
In your app-level
build.gradlefile, add the dependency for the CSQ SDK and the CSQ Compose SDK.build.gradle.kts dependencies {implementation("com.contentsquare.android:sdk:1.10.0")implementation("com.contentsquare.android:sdk-compose:1.10.0")}build.gradle dependencies {implementation 'com.contentsquare.android:sdk:1.10.0'implementation 'com.contentsquare.android:sdk-compose:1.10.0'} -
Add the Android View Autocapture Plugin to instrument your app code:
build.gradle.kts plugins {// ...id("io.heap.gradle") version "1.1.1"}build.gradle plugins {// ...id 'io.heap.gradle' version "1.1.1"} -
Once the dependencies and plugins have been added, sync Gradle and rebuild your application.
Start the SDK
Section titled Start the SDK-
Configure and start the SDK with
CSQ.start().- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
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"))}} -
Enable autocapture by setting
enableViewAutocapturetotrue.- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
MyApplication.kt CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID",options = AnalyticsOptions(enableViewAutocapture = true)))MyApplication.kt CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID",options = AnalyticsOptions(enableViewAutocapture = true))) -
(Optional) For Jetpack Compose, register the Compose Autocapture SDK.
- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQimport io.heap.autocapture.compose.ComposeAutocaptureSDKclass MyApplication : Application() {override fun onCreate() {super.onCreate()ComposeAutocaptureSDK.register()CSQ.start(context = this,StartConfig.withEnvironmentId(id = "YOUR_ENVIRONMENT_ID",options = AnalyticsOptions(enableViewAutocapture = true)))}}MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQimport io.heap.autocapture.compose.ComposeAutocaptureSDKclass MyApplication : Application() {override fun onCreate() {super.onCreate()ComposeAutocaptureSDK.register()CSQ.start(context = this,StartConfig.withDataSourceId(id = "YOUR_DATASOURCE_ID",options = AnalyticsOptions(enableViewAutocapture = true)))}} -
(Optional) If your Product Analytics environment is hosted in the EU, set the
baseUrioption tohttps://mh.ba.contentsquare.net.- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
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"))))}} -
Implement the
optIn()API to forward user consent to the SDK, generate a user ID, and initiate tracking.- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(this, StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID"))}}// ConsentActivityval optinButton: Button = findViewById(R.id.btn_accept_tracking)optinButton.setOnClickListener {CSQ.optIn()startActivity(Intent(this, MainActivity::class.java))}import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.start(this, StartConfig.withDataSourceId("YOUR_DATASOURCE_ID"))}}// ConsentActivityval optinButton: Button = findViewById(R.id.btn_accept_tracking)optinButton.setOnClickListener {CSQ.optIn()startActivity(Intent(this, MainActivity::class.java))}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.
-
Start your application, and check logs for this output:
[INFO] CSQ 1.10.0 for Product Analytics is attempting to start.
Next steps
Section titled Next stepsOur SDK offers a wide range of features to enhance your implementation, including extended tracking capabilities, and personal data masking.
Session Replay and Error Monitoring are both available with the Experience Analytics Extension, which you can purchase separately.