For the complete documentation index, see llms.txt.

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.

  1. In your app-level build.gradle file, 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")
    }
  2. Add the Android View Autocapture Plugin to instrument your app code:

    build.gradle.kts
    plugins {
    // ...
    id("io.heap.gradle") version "1.1.1"
    }
  3. Once the dependencies and plugins have been added, sync Gradle and rebuild your application.

  1. Configure and start the SDK with CSQ.start().

    MyApplication.kt
    import android.app.Application
    import com.contentsquare.CSQ
    class MyApplication : Application() {
    override fun onCreate() {
    super.onCreate()
    CSQ.start(
    context = this,
    StartConfig.withEnvironmentId(
    id = "YOUR_ENVIRONMENT_ID"
    )
    )
    }
    }
  2. Enable autocapture by setting enableViewAutocapture to true.

    MyApplication.kt
    CSQ.start(
    context = this,
    StartConfig.withEnvironmentId(
    id = "YOUR_ENVIRONMENT_ID",
    options = AnalyticsOptions(
    enableViewAutocapture = true
    )
    )
    )
  3. (Optional) For Jetpack Compose, register the Compose Autocapture SDK.

    MyApplication.kt
    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.start(
    context = this,
    StartConfig.withEnvironmentId(
    id = "YOUR_ENVIRONMENT_ID",
    options = AnalyticsOptions(
    enableViewAutocapture = true
    )
    )
    )
    }
    }
  4. (Optional) If your Product Analytics environment is hosted in the EU, set the baseUri option to https://mh.ba.contentsquare.net.

    MyApplication.kt
    import android.app.Application
    import com.contentsquare.CSQ
    class 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")
    )
    )
    )
    }
    }
  5. Implement the optIn() API to forward user consent to the SDK, generate a user ID, and initiate tracking.

    import android.app.Application
    import com.contentsquare.CSQ
    class MyApplication : Application() {
    override fun onCreate() {
    super.onCreate()
    CSQ.start(this, StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID"))
    }
    }
    // ConsentActivity
    val 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.

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

    [INFO] CSQ 1.10.0 for Product Analytics is attempting to start.

Our 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.