SDK API reference
The SDK API provides the following methods with their signatures, parameters, and usage examples.
GDPR / Identification
Section titled GDPR / IdentificationCSQ.optIn()
Section titled CSQ.optIn()1.0.0
Get user consent.
Calling this API generates a user ID and initiates tracking.
CSQ.optIn(Context)Parameters
Section titled Parameters-
Context object
Android Context object ↗
CSQ.optOut()
Section titled CSQ.optOut()1.0.0
Revoke user consent, remove stored userId.
Stop CSQ SDK, flush, and clear all data.
CSQ.optOut()Parameters
Section titled Parameters-
Context object
Android Context object ↗
CSQ.identify()
Section titled CSQ.identify()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.
CSQ.identify(identity: String)Parameters
Section titled Parameters-
identity String (<= 100 chars)
Identity to be associated with the current user.
CSQ.resetIdentity()
Section titled CSQ.resetIdentity()1.0.0
If the user was previously identified with identify(), this creates a new unidentified user and session. This is technically equivalent to calling optOut() then optIn().
CSQ.resetIdentity()Parameters
Section titled ParametersNo parameters.
CSQ.sendUserIdentifier()
Section titled CSQ.sendUserIdentifier()1.0.0
Associate a user identifier to the session.
CSQ.sendUserIdentifier(identity: String)Parameters
Section titled 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.*****
Section titled CSQ.metadata.*****1.0.0
Get all the information related to the user and project.
CSQ.metadata.userId
Section titled CSQ.metadata.userIdIdentifier of the current user. This is an identifier from Product Analytics by default or Experience Analytics if Product Analytics is not active.
CSQ.metadata.userIdCSQ.metadata.sessionId
Section titled CSQ.metadata.sessionIdSession identifier. This is an identifier from Experience Analytics by default or Product Analytics if Experience Analytics is not active.
CSQ.metadata.sessionIdCSQ.metadata.projectId
Section titled CSQ.metadata.projectIdProject identifier for Experience Analytics.
CSQ.metadata.projectIdCSQ.metadata.environmentId
Section titled CSQ.metadata.environmentIdEnvironment identifier for Product Analytics.
CSQ.metadata.environmentIdCSQ.metadata.sessionReplayUrl
Section titled CSQ.metadata.sessionReplayUrlURL of current Session Replay.
CSQ.metadata.sessionReplayUrlCSQ.metadata.identity
Section titled CSQ.metadata.identityIdentity associated with the user by calling identify().
CSQ.metadata.identityCSQ.metadata.onChanged()
Section titled CSQ.metadata.onChanged()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.
CSQ.metadata.onChanged = OnMetadataChanged { metadata -> // Handle information change}Parameters
Section titled Parameters-
metadata Metadata
Metadata associated with the current user and project.
Logging
Section titled LoggingCSQ.debug.setLogLevel()
Section titled CSQ.debug.setLogLevel()1.0.0
Sets the current log level.
CSQ.debug.logLevel = loglevelParameters
Section titled Parameters-
level Enum (CSQ.Log.Level)
Possible values:
none,trace,debug,info,warnorerror.
CSQ.debug.logChannel()
Section titled CSQ.debug.logChannel()1.0.0
Add a LogChannel to which send log messages.
CSQ.debug.logChannel = channelParameters
Section titled Parameters-
LogChannel interface
The interface where log messages will be routed.
LogChannel.printLog()
Section titled LogChannel.printLog()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.
LogChannel.printLog()Parameters
Section titled ParametersNo parameters.
Property Tracking
Section titled Property TrackingCSQ.addDynamicVar()
Section titled CSQ.addDynamicVar()Experience Analytics | Ajouté à la version : 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.
val var1 = DynamicVar("key1", "value1")val var2 = DynamicVar("key2", 10L)CSQ.addDynamicVar(var1)CSQ.addDynamicVar(var2)Parameters
Section titled Parameters-
DynamicVar object
The dynamic variable
key String (<= 512 chars)
Dynamic variable key
value String/Long
Dynamic variable value
CSQ.addUserProperties()
Section titled CSQ.addUserProperties()Product Analytics | Ajouté à la version : 1.0.0
Add a collection of properties to be associated with the current user.
CSQ.addUserProperties(properties: Map<String, Any>)Parameters
Section titled Parameters-
properties Map<String, Any>
A map of user properties.
CSQ.addEventProperties()
Section titled CSQ.addEventProperties()Product Analytics | Ajouté à la version : 1.0.0
Add a collection of properties to be associated with all future events.
CSQ.addEventProperties(properties: Map<String, Any>)Parameters
Section titled 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,Stringor Java/Kotlin object that implementsProperty
CSQ.removeEventProperty()
Section titled CSQ.removeEventProperty()Product Analytics | Ajouté à la version : 1.0.0
Removes a single property from the collection of event-wide properties.
CSQ.removeEventProperty(property: String)Parameters
Section titled Parameters-
property String
The key of the property to remove.
CSQ.clearEventProperties()
Section titled CSQ.clearEventProperties()Product Analytics | Ajouté à la version : 1.0.0
Removes all event-wide properties.
CSQ.clearEventProperties()View Tracking
Section titled View TrackingCSQ.excludeFromExposureMetric()
Section titled CSQ.excludeFromExposureMetric()Experience Analytics | Ajouté à la version : 1.0.0
Exclude a scrollable view or subclass from Exposure Metric computations.
CSQ.excludeFromExposureMetric(View)Parameters
Section titled Parameters-
View View
The view to exclude from exposure metrics.
CsqTag()
Section titled CsqTag()Experience Analytics | Ajouté à la version : 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.
enum class CsqTag { ModalBottomSheetLayout}
@Composablefun CsqTag(tag: CsqTag, block: @Composable () -> Unit)Parameters
Section titled 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 materialModalBottomSheetLayoutfor Zoning and Heatmaps. -
block @Composable () -> Unit
the composable lambda representing the UI content to be tagged
Interoperability
Section titled InteroperabilityCSQ.registerWebView()
Section titled CSQ.registerWebView()1.0.0
Register a webview for tracking.
CSQ.registerWebView(webView)Parameters
Section titled Parameters-
webView WebView
The webview to register for tracking.
CSQ.unregisterWebView()
Section titled CSQ.unregisterWebView()1.0.0
Unregister a webview for tracking.
CSQ.unregisterWebView(webView)Parameters
Section titled Parameters-
webView WebView
The webview to unregister from tracking.
Event Tracking
Section titled Event TrackingCSQ.trackTransaction()
Section titled CSQ.trackTransaction()Experience Analytics | Ajouté à la version : 1.0.0
Send a transaction.
CSQ.trackTransaction(Transaction)Parameters
Section titled Parameters-
Transaction Transaction
The transaction object to be sent.
CSQ.trackScreenview()
Section titled CSQ.trackScreenview()1.0.0
Send a screen view with or without custom variables.
CSQ.trackScreenview(name: String, cvars: List<CustomVar> = emptyList())Parameters
Section titled 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()
Section titled CSQ.trackEvent()Product Analytics | Ajouté à la version : 1.0.0
Creates an event message to be tracked and sent to the API.
CSQ.trackEvent(name: String, properties: Map<String, Any> = mapOf())Parameters
Section titled 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()
Section titled CSQ.trackMotionEvent()Experience Analytics | Ajouté à la version : 1.0.0
Track a gesture manually.
CSQ.trackMotionEvent(motionEvent: MotionEvent)Parameters
Section titled Parameters-
motionEvent MotionEvent
The MotionEvent ↗ to be tracked.
TriggeredOnResume()
Section titled TriggeredOnResume()Experience Analytics | Ajouté à la version : 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.
@ComposableTriggeredOnResume(block: () -> Unit)Parameters
Section titled Parameters-
block Function
The block of code to run when the screen is resumed.
Surveys
Section titled SurveysCSQ.triggerSurvey()
Section titled CSQ.triggerSurvey()Experience Analytics Voice of Customer | Ajouté à la version : 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.
CSQ.triggerSurvey(triggerName: String)Parameters
Section titled Parameters-
triggerName String
The name of the trigger associated with the survey. This should match the trigger name configured in the Contentsquare platform.
Example
Section titled Example// Trigger a survey after a purchase is completedCSQ.triggerSurvey("purchase-complete")Error tracking
Section titled Error trackingCSQ.setUrlMaskingPatterns()
Section titled CSQ.setUrlMaskingPatterns()Experience Analytics | Ajouté à la version : 1.0.0
Sets URL masking patterns.
CSQ.setUrlMaskingPatterns(patterns: List<String>)Parameters
Section titled Parameters-
patterns List<String>
A list of URL patterns to mask.
CSQ.trackNetworkMetric()
Section titled CSQ.trackNetworkMetric()Experience Analytics | Ajouté à la version : 1.0.0
Track network metrics.
CSQ.trackNetworkMetric(networkMetric: NetworkMetric)Parameters
Section titled Parameters-
networkMetric NetworkMetric
The network metric to be tracked.
CsqOkHttpInterceptor()
Section titled CsqOkHttpInterceptor()Experience Analytics | Ajouté à la version : 1.0.0
Intercept every OkHttp call to manually collect API errors.
val okhttpClient = OkHttpClient().newBuilder() .addInterceptor(CsqOkHttpInterceptor()) .build()Personal Data/Masking
Section titled Personal Data/MaskingCSQ.ignoreInteractions()
Section titled CSQ.ignoreInteractions()1.0.0
Ignore interactions for a specific view.
CSQ.ignoreInteractions(view: View)Parameters
Section titled ParametersView.csqIgnoreInteractions
Section titled View.csqIgnoreInteractions1.0.0
Kotlin extension function to ignore interactions for a specific view.
View.csqIgnoreInteractions()CsqIgnoreInteraction()
Section titled CsqIgnoreInteraction()Jetpack Compose composable function to ignore interactions for a specific view.
@Composablefun CsqIgnoreInteraction(ignore: Boolean, block: @Composable () -> Unit)Parameters
Section titled 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()
Section titled CSQ.setDefaultMasking()Experience Analytics | Ajouté à la version : 1.0.0
Set the default masking state.
All Android View elements, their subclasses and Jetpack Compose components are fully masked by default.
CSQ.setDefaultMasking(masked: Boolean)Parameters
Section titled Parameters-
masked Boolean
The masking state to be set.
CSQ.mask(View)
Section titled CSQ.mask(View)1.0.0
Mask a view's content.
CSQ.mask(view: View)Parameters
Section titled Parameters-
View View
The view which content will be masked.
View.csqMaskContents(enable: Boolean)
Section titled View.csqMaskContents(enable: Boolean)1.0.0
Kotlin extension function to mask the content of a view.
View.csqMaskContents(enable: Boolean)Parameters
Section titled Parameters-
enable Boolean
Whether to mask the content of the view.
CsqMask()
Section titled CsqMask()Jetpack Compose composable function that applies masking to Compose UI content This will mask both Session Replay and analytics event..
@ComposableCsqMask(enable: Boolean, block: @Composable () -> Unit)Parameters
Section titled 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)
Section titled CSQ.unmask(View)1.0.0
Unmask a view's content.
CSQ.unmask(view: View)Parameters
Section titled Parameters-
View View
The view whose content will be unmasked.
CSQ.mask(Class<?> type)
Section titled CSQ.mask(Class<?> type)Experience Analytics | Ajouté à la version : 1.0.0
Mask content for views of a specific type.
CSQ.mask(type: Class<*>)Parameters
Section titled Parameters-
type Class<?>
The class type of the view whose content will be masked.
CSQ.unmask(Class<?> type)
Section titled CSQ.unmask(Class<?> type)Experience Analytics | Ajouté à la version : 1.0.0
Unmask content for views of a specific type.
CSQ.unmask(type: Class<*>)Parameters
Section titled Parameters-
type Class<?>
The class type of the view whose content will be unmasked.
CSQ.maskTexts()
Section titled CSQ.maskTexts()1.0.0
Mask text input fields.
CSQ.maskTexts(mask: Boolean)Parameters
Section titled Parameters-
mask Boolean
Whether to mask text.
SDK initialization and management
Section titled SDK initialization and managementCSQ.configureProductAnalytics()
Section titled CSQ.configureProductAnalytics()Deprecated Product Analytics | Ajouté à la version : 1.0.0
SDK configuration method for Product Analytics. Use CSQ.start() instead, which combines configuration and initialization in a single call.
CSQ.start()
Section titled CSQ.start()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 Unified CSQ.
Experience Analytics only:
CSQ.start(context = this)Product Analytics (optionally with Experience Analytics extension) with environmentId:
CSQ.start( context = this, StartConfig.withEnvironmentId( id = "YOUR_ENVIRONMENT_ID", options = AnalyticsOptions( ) ))Unified CSQ with dataSourceId:
CSQ.start( context = this, StartConfig.withDataSourceId( id = "YOUR_DATASOURCE_ID" ))Parameters
Section titled Parameters-
context Context
Android Context object ↗
-
startConfig StartConfig (optional)
Configuration created via
StartConfig.withEnvironmentId(id, options)orStartConfig.withDataSourceId(id, options). Omit for Experience Analytics only.
CSQ.stop()
Section titled CSQ.stop()1.0.0
Stop all activity from the SDK.
Once run no requests, telemetry collection, or logs will be generated.
CSQ.stop()CSQ.pauseTracking()
Section titled CSQ.pauseTracking()1.0.0
Pause all tracking features.
CSQ.pauseTracking()CSQ.resumeTracking()
Section titled CSQ.resumeTracking()1.0.0
Resume all tracking features.
CSQ.resumeTracking()SDK configuration options
Section titled SDK configuration optionsCSQ SDK options passed to CSQ.start().
CSQ.start( context = this, StartConfig.withEnvironmentId( id = "YOUR_ENVIRONMENT_ID", options = AnalyticsOptions( ) ))baseUri
Section titled baseUriURI 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
Section titled uploadIntervalInterval in seconds at which event batches are uploaded to the API. Defaults to 15 seconds.
disablePageviewAutocapture
Section titled disablePageviewAutocaptureWhether source pageview events will be auto-captured. Defaults to false.
enableViewAutocapture
Section titled enableViewAutocaptureWhether the SDK will auto capture UI interactions and source pageviews. Only for Android View system, no Compose support. Defaults to false.
enablePushNotificationAutocapture
Section titled enablePushNotificationAutocaptureWhether the SDK will auto capture interaction events on notifications. Defaults to false.
enablePushNotificationTitleAutocapture
Section titled enablePushNotificationTitleAutocaptureWhether capture the title of the notification where an interaction was performed. enablePushNotificationAutocapture must be set to true.
Defaults to false.
enablePushNotificationBodyAutocapture
Section titled enablePushNotificationBodyAutocaptureWhether capture the body text of the notification where an interaction was performed. enablePushNotificationAutocapture must be set to true.
Defaults to false.
sessionReplayAutoStart
Section titled sessionReplayAutoStartWhether Session Replay starts automatically at SDK launch. Defaults to true.
Set to false to disable automatic start and control Session Replay manually.