---
title: SDK API reference - Android
description: SDK commands reference including signature, parameter descriptions, and examples
lastUpdated: 11 March 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/command-reference/
  md: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/command-reference/index.md
---

> Documentation index: https://docs.contentsquare.com/llms.txt
> Use this file to discover all available pages before exploring further.

The SDK API provides the following methods with their signatures, parameters, and usage examples.

## GDPR / Identification

### CSQ.optIn()

**Added in:** `1.0.0`

Get user consent.\
Calling this API generates a user ID and initiates tracking.

Call [`optIn`](#csqoptin) after [`start`](#csqstart).

```kotlin
CSQ.optIn()
```

### CSQ.optOut()

**Added in:** `1.0.0`

Revoke user consent, remove stored `userId`.\
Stop CSQ SDK, flush, and clear all data.

```kotlin
CSQ.optOut()
```

#### Parameters

* #### Context   object  

  Android [Context object ↗](https://developer.android.com/reference/android/content/Context)

### CSQ.identify()

**Added in:** `1.0.0`

Assigns an identity to be associated with the current user.

This assigns the identity to all events for the user ID and lets the analysis module merge multiple user IDs with the same identity.

Warning

Changing an identity forces a new user ID and session ID. That is, calling `identify("A"); identify("B")` creates a new user ID and session for `B`.

```kotlin
CSQ.identify(identity: String)
```

#### Parameters

* #### identity   String (<= 100 chars)  

  Identity to be associated with the current user.

### CSQ.resetIdentity()

**Added in:** `1.0.0`

If the user was previously identified with [`identify()`](#csqidentify), this creates a new unidentified user and session. This is technically equivalent to calling [`optOut()`](#csqoptout) then [`optIn()`](#csqoptin).

```kotlin
CSQ.resetIdentity()
```

#### Parameters

* No parameters.

### CSQ.sendUserIdentifier()

**Added in:** `1.0.0`

Associate a user identifier to the session.

```kotlin
CSQ.sendUserIdentifier(identity: String)
```

#### Parameters

* #### identity   String (<= 100 chars)  

  The string value representing the user identifier to be associated with the current session. Should be max 100 characters long.

### CSQ.metadata.\*\*\*\*\*

**Added in:** `1.0.0`

Get all the information related to the user and project.

#### CSQ.metadata.userId

Identifier of the current user. This is an identifier from Product Analytics by default or Experience Analytics if Product Analytics is not active.

```kotlin
CSQ.metadata.userId
```

#### CSQ.metadata.sessionId

Session identifier. This is an identifier from Experience Analytics by default or Product Analytics if Experience Analytics is not active.

```kotlin
CSQ.metadata.sessionId
```

#### CSQ.metadata.projectId

Project identifier for Experience Analytics.

```kotlin
CSQ.metadata.projectId
```

#### CSQ.metadata.environmentId

Environment identifier for Product Analytics.

```kotlin
CSQ.metadata.environmentId
```

#### CSQ.metadata.sessionReplayUrl

URL of current Session Replay.

```kotlin
CSQ.metadata.sessionReplayUrl
```

#### CSQ.metadata.identity

Identity associated with the user by calling [`identify()`](#csqidentify).

```kotlin
CSQ.metadata.identity
```

### CSQ.metadata.onChanged()

**Added in:** `1.0.0`

A block triggered each time user information is updated. For example when `sessionReplayUrl` becomes available or `userId` updates. Set this block to subscribe to the updates. Contentsquare will call this block with updated metadata.

Note

This may not trigger on changes to Product Analytics data.

```kotlin
CSQ.metadata.onChanged = OnMetadataChanged { metadata ->
    // Handle information change
}
```

#### Parameters

* #### metadata   Metadata  

  Metadata associated with the current user and project.

## Logging

### CSQ.debug.setLogLevel()

**Added in:** `1.0.0`

Sets the current log level.

```kotlin
CSQ.debug.logLevel = loglevel
```

#### Parameters

* #### level   Enum (CSQ.Log.Level)  

  Possible values: `none`, `trace`, `debug`, `info`, `warn` or `error`.

### CSQ.debug.logChannel()

**Added in:** `1.0.0`

Add a `LogChannel` to which send log messages.

```kotlin
CSQ.debug.logChannel = channel
```

#### Parameters

* #### LogChannel   interface  

  The interface where log messages will be routed.

### LogChannel.printLog()

**Added in:** `1.0.0`

Routes SDK logs to another location such as Timber, Arbor, or similar logging libraries. The default implementation routes all logs through Logcat.

```kotlin
LogChannel.printLog()
```

#### Parameters

* No parameters.

## Property Tracking

### CSQ.addDynamicVar()

Experience Analytics | **Added in:** `1.0.0`

Adds one or multiple dynamic variables to the session properties. This method allows you to pass a `DynamicVar` object, representing a key-value pair that is scoped to the session.

```kotlin
val var1 = DynamicVar("key1", "value1")
val var2 = DynamicVar("key2", 10L)
CSQ.addDynamicVar(var1)
CSQ.addDynamicVar(var2)
```

#### Parameters

* #### DynamicVar   object  

  The dynamic variable

  * #### key   String (<= 512 chars)  

    Dynamic variable key

  * #### value   String/Long  

    Dynamic variable value

### CSQ.addUserProperties()

Product Analytics | **Added in:** `1.0.0`

Add a collection of properties to be associated with the current user.

```kotlin
CSQ.addUserProperties(properties: Map<String, Any>)
```

#### Parameters

* #### properties   Map\<String, Any>  

  A map of user properties.

### CSQ.addEventProperties()

Product Analytics | **Added in:** `1.0.0`

Add a collection of properties to be associated with all future events.

```kotlin
CSQ.addEventProperties(properties: Map<String, Any>)
```

#### Parameters

* #### properties   Map\<String, Any>  

  A map of event properties.

  * #### key   String  

    the UserProperty key

  * #### value   Any  

    values can be any combination of any `Number`, `Boolean`, `String` or Java/Kotlin object that implements `Property`

### CSQ.removeEventProperty()

Product Analytics | **Added in:** `1.0.0`

Removes a single property from the collection of event-wide properties.

```kotlin
CSQ.removeEventProperty(property: String)
```

#### Parameters

* #### property   String  

  The key of the property to remove.

### CSQ.clearEventProperties()

Product Analytics | **Added in:** `1.0.0`

Removes all event-wide properties.

```kotlin
CSQ.clearEventProperties()
```

## View Tracking

### CSQ.excludeFromExposureMetric()

Experience Analytics | **Added in:** `1.0.0`

Exclude a scrollable view or subclass from Exposure Metric computations.

Warning

Currently iOS-only, applicable on `UIScrollView` or a class inheriting from `UIScrollView`. Android-only application on `ScrollView` & `RecyclerView`.

```kotlin
CSQ.excludeFromExposureMetric(View)
```

#### Parameters

* #### View   View  

  The view to exclude from exposure metrics.

### CsqTag()

Experience Analytics | **Added in:** `1.4.4`

Jetpack Compose composable function for tagging composables that require special handling by SDK. It is currently used to enable support for material `ModalBottomSheetLayout` in Zoning and Heatmap analysis.

```kotlin
enum class CsqTag {
  ModalBottomSheetLayout
}


@Composable
fun CsqTag(tag: CsqTag, block: @Composable () -> Unit)
```

#### Parameters

* #### tag   Enum (CsqTag)  

  indicates the type of special handling required by the SDK

  `CsqTag.ModalBottomSheetLayout` - enables the SDK to properly capture and analyze content within a material `ModalBottomSheetLayout` for Zoning and Heatmaps.

* #### block   @Composable () -> Unit  

  the composable lambda representing the UI content to be tagged

## Interoperability

### CSQ.registerWebView()

**Added in:** `1.0.0`

Register a webview for tracking.

```kotlin
CSQ.registerWebView(webView)
```

#### Parameters

* #### webView   WebView  

  The webview to register for tracking.

### CSQ.unregisterWebView()

**Added in:** `1.0.0`

Unregister a webview for tracking.

```kotlin
CSQ.unregisterWebView(webView)
```

#### Parameters

* #### webView   WebView  

  The webview to unregister from tracking.

## Event Tracking

### CSQ.trackTransaction()

Experience Analytics | **Added in:** `1.0.0`

Send a transaction.

```kotlin
CSQ.trackTransaction(Transaction)
```

#### Parameters

* #### Transaction   Transaction  

  The transaction object to be sent.

### CSQ.trackScreenview()

**Added in:** `1.0.0`

Send a screen view with or without custom variables.

```kotlin
CSQ.trackScreenview(name: String, cvars: List<CustomVar> = emptyList())
```

#### Parameters

* #### name   String  

  The name of the screen.

* #### cvars   List\<CustomVar> (optional)  

  A list of custom variables to attach to the screen view.

  * #### index   Int (@IntRange(from = 0, to = 20))  

    A number identifying a CustomVar

  * #### name   String (<= 512 chars)  

    Custom variable key

  * #### value   String  

    Custom variable value

### CSQ.trackEvent()

Product Analytics | **Added in:** `1.0.0`

Creates an event message to be tracked and sent to the API.

```kotlin
CSQ.trackEvent(name: String, properties: Map<String, Any> = mapOf())
```

#### Parameters

* #### name   String  

  The name of the event to be tracked.

* #### properties   Map\<String, Any> (optional)  

  Optional properties to associate with the event.

### CSQ.trackMotionEvent()

Experience Analytics | **Added in:** `1.0.0`

Track a gesture manually.

```kotlin
CSQ.trackMotionEvent(motionEvent: MotionEvent)
```

#### Parameters

* #### motionEvent   MotionEvent  

  The [MotionEvent ↗](https://developer.android.com/reference/android/view/MotionEvent) to be tracked.

### TriggeredOnResume()

Experience Analytics | **Added in:** `1.0.0`

Helper function for Jetpack Compose to ensure only one screen view is triggered when a given screen is presented to the user.

```kotlin
@Composable
TriggeredOnResume(block: () -> Unit)
```

#### Parameters

* #### block   Function  

  The block of code to run when the screen is resumed.

## Surveys

### CSQ.triggerSurvey()

Experience Analytics Voice of Customer | **Added in:** `1.0.0`

Triggers a survey by referencing a predefined trigger name.

This method allows your mobile app to trigger surveys at specific moments in the user journey. Triggers act as flexible placeholders that are not bound to individual surveys, enabling your business team to assign or update surveys later without requiring code changes.

```kotlin
CSQ.triggerSurvey(triggerName: String)
```

#### Parameters

* #### triggerName   String  

  The name of the trigger associated with the survey. This should match the trigger name configured in the Contentsquare platform.

#### Example

```kotlin
// Trigger a survey after a purchase is completed
CSQ.triggerSurvey("purchase-complete")
```

## Error tracking

### CSQ.setUrlMaskingPatterns()

Experience Analytics | **Added in:** `1.0.0`

Sets URL masking patterns.

```kotlin
CSQ.setUrlMaskingPatterns(patterns: List<String>)
```

#### Parameters

* #### patterns   List\<String>  

  A list of URL patterns to mask.

### CSQ.trackNetworkMetric()

Experience Analytics | **Added in:** `1.0.0`

Track network metrics.

```kotlin
CSQ.trackNetworkMetric(networkMetric: NetworkMetric)
```

#### Parameters

* #### networkMetric   NetworkMetric  

  The network metric to be tracked.

### CsqOkHttpInterceptor()

Experience Analytics | **Added in:** `1.0.0`

Intercept every OkHttp call to manually collect API errors.

```kotlin
val okhttpClient = OkHttpClient().newBuilder()
        .addInterceptor(CsqOkHttpInterceptor())
        .build()
```

## Personal Data/Masking

### CSQ.ignoreInteractions()

**Added in:** `1.0.0`

Ignore interactions for a specific view.

```kotlin
CSQ.ignoreInteractions(view: View)
```

#### Parameters

### View\.csqIgnoreInteractions

**Added in:** `1.0.0`

Kotlin extension function to ignore interactions for a specific view.

```kotlin
View.csqIgnoreInteractions()
```

### CsqIgnoreInteraction()

Jetpack Compose composable function to ignore interactions for a specific view.

```kotlin
@Composable
fun CsqIgnoreInteraction(ignore: Boolean, block: @Composable () -> Unit)
```

#### Parameters

* #### ignore   Boolean  

  indicating whether interactions should be ignored or not

* #### block   @Composable () -> Unit  

  composable lambda function representing the UI content to apply ignore condition

### CSQ.setDefaultMasking()

Experience Analytics | **Added in:** `1.0.0`

Set the default masking state.\
All Android View elements, their subclasses and Jetpack Compose components are fully masked by default.

```kotlin
CSQ.setDefaultMasking(masked: Boolean)
```

#### Parameters

* #### masked   Boolean  

  The masking state to be set.

### CSQ.mask(View)

**Added in:** `1.0.0`

Mask a view's content.

```kotlin
CSQ.mask(view: View)
```

#### Parameters

* #### View   View  

  The view which content will be masked.

### View\.csqMaskContents(enable: Boolean)

**Added in:** `1.0.0`

Kotlin extension function to mask the content of a view.

```kotlin
View.csqMaskContents(enable: Boolean)
```

#### Parameters

* #### enable   Boolean  

  Whether to mask the content of the view.

### CsqMask()

Jetpack Compose composable function that applies masking to Compose UI content This will mask both Session Replay and analytics event..

```kotlin
@Composable
CsqMask(enable: Boolean, block: @Composable () -> Unit)
```

#### Parameters

* #### enable   Boolean  

  Whether to mask the content of the view.

* #### block   @Composable () -> Unit  

  composable lambda function representing the content to apply masking condition

### CSQ.unmask(View)

**Added in:** `1.0.0`

Unmask a view's content.

```kotlin
CSQ.unmask(view: View)
```

#### Parameters

* #### View   View  

  The view whose content will be unmasked.

### CSQ.mask(Class\<?> type)

Experience Analytics | **Added in:** `1.0.0`

Mask content for views of a specific type.

```kotlin
CSQ.mask(type: Class<*>)
```

#### Parameters

* #### type   Class\<?>  

  The class type of the view whose content will be masked.

### CSQ.unmask(Class\<?> type)

Experience Analytics | **Added in:** `1.0.0`

Unmask content for views of a specific type.

```kotlin
CSQ.unmask(type: Class<*>)
```

#### Parameters

* #### type   Class\<?>  

  The class type of the view whose content will be unmasked.

### CSQ.maskTexts()

**Added in:** `1.0.0`

Mask text input fields.

```kotlin
CSQ.maskTexts(mask: Boolean)
```

#### Parameters

* #### mask   Boolean  

  Whether to mask text.

## SDK initialization and management

### CSQ.configureProductAnalytics()

Deprecated Product Analytics | **Added in:** `1.0.0`

SDK configuration method for Product Analytics. Use [`CSQ.start()`](#csqstart) instead, which combines configuration and initialization in a single call.

### CSQ.start()

**Added in:** `1.0.0`

Start the SDK. This method combines configuration and initialization in a single call.

There are three overloads depending on whether you want Experience Analytics, Product Analytics, or CSQ Experience Platform.

**Experience Analytics only:**

```kotlin
CSQ.start(context = this)
```

**Product Analytics (optionally with Experience Analytics extension) with `environmentId`:**

```kotlin
CSQ.start(
  context = this,
  StartConfig.withEnvironmentId(
    id = "YOUR_ENVIRONMENT_ID",
    options = AnalyticsOptions(
      enableViewAutocapture = true
    )
  )
)
```

**CSQ Experience Platform with `dataSourceId`:**

```kotlin
CSQ.start(
  context = this,
  StartConfig.withDataSourceId(
    id = "YOUR_DATASOURCE_ID"
  )
)
```

#### Parameters

* #### context   Context  

  Android [Context object ↗](https://developer.android.com/reference/android/content/Context)

* #### startConfig   StartConfig (optional)  

  Configuration created via `StartConfig.withEnvironmentId(id, options)` or `StartConfig.withDataSourceId(id, options)`. Omit for Experience Analytics only.

### CSQ.stop()

**Added in:** `1.0.0`

Stop all activity from the SDK.\
Once run no requests, telemetry collection, or logs will be generated.

```kotlin
CSQ.stop()
```

### CSQ.pauseTracking()

**Added in:** `1.0.0`

Pause all tracking features.

```kotlin
CSQ.pauseTracking()
```

### CSQ.resumeTracking()

**Added in:** `1.0.0`

Resume all tracking features.

```kotlin
CSQ.resumeTracking()
```

### CSQ.startSessionReplay()

**Added in:** `1.10.0`

Enable and eventually start Session Replay independently of other CSQ SDK features, allowing for on-demand collection. To use this functionality, disable the automatic start of Session Replay at SDK initialization using the [`.sessionReplayAutoStart`](#sessionreplayautostart) option.

```kotlin
CSQ.startSessionReplay()
```

### CSQ.stopSessionReplay()

**Added in:** `1.10.0`

Stop Session Replay immediately.

```kotlin
CSQ.stopSessionReplay()
```

## SDK configuration options

CSQ SDK options passed to [`CSQ.start()`](#csqstart).

```kotlin
// optional: StartConfig.withEnvironmentId(id: String, options) | StartConfig.withDataSourceId(id: String)
CSQ.start(
  context = this,
  StartConfig.withEnvironmentId(
    id = "YOUR_ENVIRONMENT_ID",
    options = AnalyticsOptions(
      enableViewAutocapture = true,
      baseUri = URI.create("https://example.com/"),
      uploadInterval = 15.0,
      disablePageviewAutocapture = false,
      enablePushNotificationAutocapture = true,
      enablePushNotificationTitleAutocapture = true,
      enablePushNotificationBodyAutocapture = false,
      sessionReplayAutoStart = false
    )
  )
)
```

### `baseUri`

URI object specifying the base URI for the desired API endpoint. The CSQ SDK resolves paths using this base URI and ignores any pre-existing path elements.

### `uploadInterval`

Interval in seconds at which event batches are uploaded to the API. Defaults to 15 seconds.

### `disablePageviewAutocapture`

Whether source pageview events will be auto-captured. Defaults to false.

### `enableViewAutocapture`

Whether the SDK will auto capture UI interactions and source pageviews. Only for Android View system, no Compose support. Defaults to false.

### `enablePushNotificationAutocapture`

Whether the SDK will auto capture interaction events on notifications. Defaults to false.

### `enablePushNotificationTitleAutocapture`

Whether capture the title of the notification where an interaction was performed. `enablePushNotificationAutocapture` must be set to `true`. Defaults to false.

### `enablePushNotificationBodyAutocapture`

Whether capture the body text of the notification where an interaction was performed. `enablePushNotificationAutocapture` must be set to `true`. Defaults to false.

### `maximumDatabaseSize`

The maximum size, in bytes, to allocate for the local event storage database. Defaults to -1, meaning there is no limit on database size. Must be greater than or equal to 200KB.

### `messageBatchMessageLimit`

The maximum number of messages to be included in each batch sent to Contentsquare Product Analytics. Setting a lower limit can help reduce network traffic in situations where bandwidth is limited. Defaults to 100.

### `maximumBatchCountPerUpload`

The maximum number of batches to send per upload cycle. This can be used in conjunction with messageBatchMessageLimit to control the amount of data that is uploaded in a given cycle.

### `resumePreviousSession`

Enables Contentsquare behavior of persisting non-expired sessions across app launch.

### `pruningLookBackWindow`

The number of days to look back when pruning old data in days. Defaults to 6 days. Requires an entitlement to use.

### `sessionReplayAutoStart`

Whether Session Replay starts automatically at SDK launch. Defaults to `true`.

Set to `false` to disable automatic start and control Session Replay manually.
