Setup product analytics data capture

Prerequisites:

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

    MyApplication.kt
    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()
    }
    }
  2. Set up autocapture by adding enableViewAutocapture = true.

    MyApplication.kt
    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()
    }
    }
  3. (Optional) For Jetpack Compose, add the dedicated import and 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.configureProductAnalytics(
    context = this,
    envId = "YOUR_ENVIRONMENT_ID",
    options = ProductAnalyticsOptions(
    enableViewAutocapture = true
    )
    )
    CSQ.start()
    }
    }
  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.configureProductAnalytics(
    context = this,
    envId = "YOUR_ENVIRONMENT_ID",
    options = ProductAnalyticsOptions(
    enableViewAutocapture = true,
    baseUri = URI("https://mh.ba.contentsquare.net")
    )
    )
    }
    }
  5. Add the resumePreviousSession: true and disablePageviewAutocapture: true options to the configuration.

    MyApplication.kt
    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()
    }
    }