SDK API reference
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)
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()
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)
CSQ.identify(String identity);
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()
CSQ.resetIdentity();
Parameters
Section titled ParametersNo parameters.
CSQ.metadata.*****
Section titled CSQ.metadata.*****1.0.0
Get all information relative to the user.
CSQ.metadata.userId
Section titled CSQ.metadata.userIdCSQ.metadata.userId;
CSQ.metadata.getUserId();
CSQ.metadata.sessionId
Section titled CSQ.metadata.sessionIdCSQ.metadata.sessionId
CSQ.metadata.getSessionId();
CSQ.metadata.projectId
Section titled CSQ.metadata.projectIdCSQ.metadata.projectId
CSQ.metadata.getProjectId();
CSQ.metadata.environmentId
Section titled CSQ.metadata.environmentIdCSQ.metadata.environmentId;
CSQ.metadata.getEnvironmentId();
CSQ.metadata.sessionReplayUrl
Section titled CSQ.metadata.sessionReplayUrlCSQ.metadata.sessionReplayUrl
CSQ.metadata.getSessionReplayUrl();
CSQ.metadata.onChanged()
Section titled CSQ.metadata.onChanged()1.0.0
Trigger a callback whenever user information is updated.
CSQ.metadata.onChanged { metadata -> // Handle information change}
CSQ.metadata.setOnChanged(new new OnMetadataChanged() { @Override public void invoke(@NonNull Metadata metadata) { // Handle information change }});
Parameters
Section titled Parameters-
onMetadataChanged OnMetadataChanged
Callback triggered each time a metadata data change.
Logging
Section titled LoggingCSQ.debug.setLogLevel()
Section titled CSQ.debug.setLogLevel()1.0.0
Sets the current log level.
CSQ.debug.logLevel = loglevel
CSQ.debug.setLogLevel(level);
Parameters
Section titled Parameters-
level Enum (CSQ.Log.Level)
Possible values:
none
,trace
,debug
,info
,warn
orerror
.
CSQ.debug.logChannel()
Section titled CSQ.debug.logChannel()1.0.0
Add a LogChannel
to which send log messages.
CSQ.debug.logChannel = channel
CSQ.debug.setLogChannel(channel);
Parameters
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()
LogChannel.printLog();
Parameters
Section titled ParametersNo parameters.
Property Tracking
Section titled Property TrackingCSQ.addDynamicVar()
Section titled 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.
val var1 = DynamicVar("key1", "value1")val var2 = DynamicVar("key2", 10L)CSQ.addDynamicVar(var1)CSQ.addDynamicVar(var2)
DynamicVar var1 = new DynamicVar("key1", "value1");DynamicVar var2 = new 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 | Added in: 1.0.0
Add a collection of properties to be associated with the current user.
CSQ.addUserProperties(properties: Map<String, Any>)
CSQ.addUserProperties(Map<String, Object> properties);
Parameters
Section titled Parameters-
properties Map<String, Any>
A map of user properties.
CSQ.addEventProperties()
Section titled CSQ.addEventProperties()Product Analytics | Added in: 1.0.0
Add a collection of properties to be associated with all future events.
CSQ.addEventProperties(properties: Map<String, Any>)
CSQ.addEventProperties(Map<String, Object> properties);
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
,String
or Java/Kotlin object that implementsProperty
CSQ.removeEventProperty()
Section titled CSQ.removeEventProperty()Product Analytics | Added in: 1.0.0
Removes a single property from the collection of event-wide properties.
CSQ.removeEventProperty(property: String)
CSQ.removeEventProperty(String property);
Parameters
Section titled Parameters-
property String
The key of the property to remove.
CSQ.clearEventProperties()
Section titled CSQ.clearEventProperties()Product Analytics | Added in: 1.0.0
Removes all event-wide properties.
CSQ.clearEventProperties()
CSQ.clearEventProperties();
View Tracking
Section titled View TrackingCSQ.excludeFromExposureMetric()
Section titled CSQ.excludeFromExposureMetric()Experience Analytics | Added in: 1.0.0
Exclude a scrollable view or subclass from Exposure Metric computations.
CSQ.excludeFromExposureMetric(View)
CSQ.excludeFromExposureMetric(View);
Parameters
Section titled Parameters-
View View
The view to exclude from exposure metrics.
Interoperability
Section titled InteroperabilityCSQ.registerWebView()
Section titled CSQ.registerWebView()1.0.0
Register a webview for tracking.
CSQ.registerWebView(webView)
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)
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 | Added in: 1.0.0
Send a transaction.
CSQ.trackTransaction(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())
CSQ.trackScreenview(String name, List<CustomVar> cvars);
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 | Added in: 1.0.0
Creates an event message to be tracked and sent to the API.
CSQ.trackEvent(name: String, properties: Map<String, Any> = mapOf())
CSQ.trackEvent(String name , Map<String, Object> properties);
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 | Added in: 1.0.0
Track a gesture manually.
CSQ.trackMotionEvent(motionEvent: MotionEvent)
CSQ.trackMotionEvent(MotionEvent motionEvent);
Parameters
Section titled Parameters-
motionEvent MotionEvent
The MotionEvent ↗ to be tracked.
TriggeredOnResume()
Section titled 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.
@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 | 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.
CSQ.triggerSurvey(triggerName: String)
CSQ.triggerSurvey(String triggerName);
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")
// Trigger a survey after a purchase is completedCSQ.triggerSurvey("purchase-complete");
Error tracking
Section titled Error trackingCSQ.setUrlMaskingPatterns()
Section titled CSQ.setUrlMaskingPatterns()Experience Analytics | Added in: 1.0.0
Sets URL masking patterns.
CSQ.setUrlMaskingPatterns(patterns: List<String>)
CSQ.setUrlMaskingPatterns(List<String> patterns);
Parameters
Section titled Parameters-
patterns List<String>
A list of URL patterns to mask.
CSQ.trackNetworkMetric()
Section titled CSQ.trackNetworkMetric()Experience Analytics | Added in: 1.0.0
Track network metrics.
CSQ.trackNetworkMetric(networkMetric: NetworkMetric)
CSQ.trackNetworkMetric(NetworkMetric networkMetric);
Parameters
Section titled Parameters-
networkMetric NetworkMetric
The network metric to be tracked.
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)
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 | 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.
CSQ.setDefaultMasking(masked: Boolean)
CSQ.setDefaultMasking(Boolean masked);
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)
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)
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 | Added in: 1.0.0
Mask content for views of a specific type.
CSQ.mask(type: Class<*>)
CSQ.mask(Class<?> type);
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 | Added in: 1.0.0
Unmask content for views of a specific type.
CSQ.unmask(type: Class<*>)
CSQ.unmask(Class<?> type);
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)
CSQ.maskTexts(Boolean mask);
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()Product Analytics | Added in: 1.0.0
Product Analytics is configured using this method. Must be called before the start of the SDK.
CSQ.configureProductAnalytics( context = this, options = ProductAnalyticsOptions( ))
ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder() .build();
Parameters
Section titled Parameters-
context Context
Android Context object ↗
-
envId string
Your Product Analytics environment ID.
-
ProductAnalyticsOptions()
Product Analytics initialization options.
CSQ.start()
Section titled CSQ.start()1.0.0
Manually start the SDK.
CSQ.start(context)
CSQ.start(context);
Parameters
Section titled Parameters-
context Context
Android Context object ↗
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.stop();
CSQ.pauseTracking()
Section titled CSQ.pauseTracking()1.0.0
Pause all tracking features.
CSQ.pauseTracking()
CSQ.pauseTracking();
CSQ.resumeTracking()
Section titled CSQ.resumeTracking()1.0.0
Resume all tracking features.
CSQ.resumeTracking()
CSQ.resumeTracking();
Product Analytics initialization options
Section titled Product Analytics initialization optionsCSQ SDK options for Product Analytics passed to CSQ.configureProductAnalytics()
.
CSQ.configureProductAnalytics( options = ProductAnalyticsOptions( ))
ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder() .build();
envId
Section titled envIdProduct Analytics Environment ID.
uploadInterval
Section titled uploadIntervalInterval at which event batches should be uploaded to the API. Defaults to 15 seconds.
baseUri
Section titled baseUriURI object specifying the base URI for the desired API endpoint. The Heap SDK resolves paths using this base URI and ignores any pre-existing path elements.
captureVendorId
Section titled captureVendorIdWhether or not the vendor ID should be included in tracked events if made available by the device. Defaults to false.
captureAdvertiserId
Section titled captureAdvertiserIdWhether or not the advertiser ID should be included in tracked events if made available by the device. Defaults to false.
clearEventPropertiesOnNewUser
Section titled clearEventPropertiesOnNewUserWhether or not to clear event properties when a new user is created. Defaults to false.
disablePageviewAutocapture
Section titled disablePageviewAutocaptureWhether or not source pageview events will be auto-captured. Defaults to false.
enableViewAutocapture
Section titled enableViewAutocaptureWhether or not the SDK will auto captureUI interactions and source pageviews. Only for Android View system, no Compose support. Defaults to false.
enablePushNotificationAutocapture
Section titled enablePushNotificationAutocaptureWhether or not the SDK will auto capture interaction events on notifications. Defaults to false.
enablePushNotificationTitleAutocapture
Section titled enablePushNotificationTitleAutocaptureWhether or not capture the title of the notification where an interaction was performed. enablePushNotificationAutocapture
must be to true.
Defaults to false.
enablePushNotificationBodyAutocapture
Section titled enablePushNotificationBodyAutocaptureWhether or not capture the body text of the notification where an interaction was performed. enablePushNotificationAutocapture
must be to true.
Defaults to false.
maximumDatabaseSize
Section titled maximumDatabaseSizeThe 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
Section titled messageBatchMessageLimitThe maximum number of messages to be included in each batch sent to Heap. Setting a lower limit can help reduce network traffic in situations where bandwidth is limited. Defaults to 100.
maximumBatchCountPerUpload
Section titled maximumBatchCountPerUploadThe 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
Section titled resumePreviousSessionEnables Contentsquare behavior of persisting non-expired sessions across app launch.
pruningLookBackWindow
Section titled pruningLookBackWindowThe number of days to look back when pruning old data in days. Defaults to 6 days. Requires an entitlement to use.
initialSessionMetadata
Section titled initialSessionMetadataInstead of starting a new session with a new user, metadata can be passed in to specify initial metadata. Doing this causes all session expiration logic to be suspended. Defaults to null. Requires an entitlement to use.
disableScreenviewForwardToDXA
Section titled disableScreenviewForwardToDXADisable forwarding of Product Analytics Pageviews to Experience Analytics.
disableScreenviewForwardToPA
Section titled disableScreenviewForwardToPADisable forwarding of Experience Analytics Screenviews to Product Analytics.