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.
await CSQ().optIn();Parameters
Section titled ParametersNo parameters.
CSQ().optOut()
Section titled CSQ().optOut()1.0.0
Revoke user consent, remove stored userID.
Stop CSQ SDK, flush, and clear all data.
await CSQ().optOut();Parameters
Section titled ParametersNo parameters.
CSQ().identify()
Section titled CSQ().identify()Product Analytics | 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.
This should be called only after Product Analytics is configured and the SDK started. It's safe to call multiple times with the same value. Always provide a value that will be unique to this user. Setting values like "guest", "anonymous", "unauthenticated" or similar will merge all those users into a single user profile.
await CSQ().identify(userIdentifier: 'userIdentity');Parameters
Section titled Parameters-
userIdentifier 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 similar to calling optOut() then optIn().
This should be called only after Product Analytics is configured and the SDK started.
await CSQ().resetIdentity();Parameters
Section titled ParametersNo parameters.
CSQ().metadata
Section titled CSQ().metadata1.0.0
Get all the information related to the user and project.
CSQ().metadata.userId
Section titled CSQ().metadata.userIdIdentifier of the current user.
final userId = CSQ().metadata.userId;CSQ().metadata.sessionId
Section titled CSQ().metadata.sessionIdSession identifier.
final sessionId = CSQ().metadata.sessionId;CSQ().metadata.projectId
Section titled CSQ().metadata.projectIdProject identifier for Experience Analytics.
final projectId = CSQ().metadata.projectId;CSQ().metadata.environmentId
Section titled CSQ().metadata.environmentIdEnvironment identifier for Experience Analytics.
final environmentId = CSQ().metadata.environmentId;CSQ().metadata.sessionReplayUrl
Section titled CSQ().metadata.sessionReplayUrlURL of current Session Replay.
final sessionReplayUrl = CSQ().metadata.sessionReplayUrl;CSQ().metadata.identity
Section titled CSQ().metadata.identityIdentity associated with the user by calling identify().
final identity = CSQ().metadata.identity;CSQ().metadata.onChange()
Section titled CSQ().metadata.onChange()1.0.0
Listen for changes to user metadata. For example when sessionReplayUrl becomes available or userId updates.
final subscription = CSQ().metadata.onChange((metadata) { // Handle information change});
// Cancel when no longer neededsubscription.cancel();Parameters
Section titled Parameters-
handler void Function(Metadata metadata)
Callback triggered whenever metadata changes. Called immediately with current metadata if available.
Logging
Section titled LoggingCSQ().debug.setLogLevel()
Section titled CSQ().debug.setLogLevel()1.0.0
Sets the current log level.
await CSQ().debug.setLogLevel(LogLevel.debug);Parameters
Section titled Parameters-
logLevel Enum (LogLevel)
Possible values:
all,trace,debug,info,warning,error,important, ornone.
Property Tracking
Section titled Property TrackingCSQ().addDynamicVar()
Section titled CSQ().addDynamicVar()Experience Analytics | Added in: 1.0.0
Adds dynamic variables to the session properties.
This method allows you to pass DynamicVar objects, representing key-value pairs that are scoped to the session.
final var1 = DynamicVar.fromString(key: 'key1', value: 'value1');final var2 = DynamicVar.fromInt(key: 'key2', value: 2);
await CSQ().addDynamicVar(var1);await CSQ().addDynamicVar(var2);Parameters
Section titled Parameters-
dynamicVar DynamicVar
The dynamic variable
key String (<= 50 chars)
Dynamic variable key
value int or String
Dynamic variable value. Use
DynamicVar.fromIntfor integer values (0 to 2³² - 1) orDynamicVar.fromStringfor string values (<= 255 chars).
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.
await CSQ().addUserProperties(properties: {'propertyKey': 'propertyValue'});Parameters
Section titled Parameters-
properties Map<String, dynamic>
A map of user properties. Supported value types:
String,num,bool. All other types will be ignored.
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.
await CSQ().addEventProperties(properties: {'propertyKey': 'propertyValue'});Parameters
Section titled Parameters-
properties Map<String, dynamic>
A map of event properties. Supported value types:
String,num,bool. All other types will be ignored.
CSQ().removeEventProperty()
Section titled CSQ().removeEventProperty()Product Analytics | Added in: 1.0.0
Removes a single property from the collection of event-wide properties.
await CSQ().removeEventProperty(name: 'propertyKey');Parameters
Section titled Parameters-
name 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.
await CSQ().clearEventProperties();Interoperability
Section titled InteroperabilityCSQWebViewWrapper
Section titled CSQWebViewWrapperExperience Analytics | Added in: 1.0.0
Widget that enables CSQ tracking inside a WebView. Wrap your WebView widget with CSQWebViewWrapper and pass a delegate that supplies the WebView.
To enable WebView support, you must also implement the CSQ WebView JavaScript Tracking Tag in the web pages loaded by the WebView.
Two delegate types are available depending on your WebView package:
UserScriptWebViewWrapperDelegate— for packages likeflutter_inappwebviewthat support user scriptsJSChannelWebViewWrapperDelegate— for packages likewebview_flutterthat use JavaScript channels
// Using UserScriptWebViewWrapperDelegate (for example flutter_inappwebview)CSQWebViewWrapper( delegate: UserScriptWebViewWrapperDelegate( builder: (context, userScript) { return InAppWebView( initialUserScripts: UnmodifiableListView([ UserScript( source: userScript, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START, ), ]), ); }, ),)
// Using JSChannelWebViewWrapperDelegate (for example webview_flutter)CSQWebViewWrapper( delegate: JSChannelWebViewWrapperDelegate( addJavaScriptChannel: (handler) { webViewController.addJavaScriptChannel( handler.channelName, onMessageReceived: (jsMessage) { handler.onMessageReceived(jsMessage.message); }, ); }, builder: (context) => WebViewWidget(controller: webViewController), ),)Parameters
Section titled Parameters-
delegate WebViewWrapperDelegate
The delegate that supplies the WebView widget to be wrapped.
Event Tracking
Section titled Event TrackingCSQ().trackTransaction()
Section titled CSQ().trackTransaction()Experience Analytics | Added in: 1.0.0
Send a transaction.
final transaction = Transaction( price: 100.0, currency: Currency.USD, id: 'transactionId',);await CSQ().trackTransaction(transaction);Parameters
Section titled Parameters-
transaction Transaction
The transaction object to be sent.
price double
The total transaction amount.
currency Currency
ISO 4217 currency enum value. For example:
Currency.USD,Currency.EUR,Currency.GBP.
id String (optional)
Optional transaction identifier.
CSQ().trackScreenview()
Section titled CSQ().trackScreenview()1.0.0
Send a screen view with or without custom variables. Requires Experience Analytics to be started.
await CSQ().trackScreenview( screenName: 'ScreenName', customVars: [CustomVar(index: 1, name: 'name', value: 'value')],);Parameters
Section titled Parameters-
screenName String
The name of the screen.
-
customVars List<CustomVar> (optional)
A list of custom variables to attach to the screen view.
index int
Custom variable index
name String (<= 512 chars)
Custom variable name
value String (<= 256 chars)
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.
await CSQ().trackEvent( eventName: 'EventName', properties: {'propertyKey': 'propertyValue'},);Parameters
Section titled Parameters-
eventName String
The name of the event to be tracked.
-
properties Map<String, dynamic> (optional)
Optional properties to associate with the event. Supported value types:
String,num,bool. All other types will be ignored.
Error tracking
Section titled Error trackingCSQ().setURLMaskingPatterns()
Section titled CSQ().setURLMaskingPatterns()Experience Analytics | Added in: 1.0.0
Sets URL masking patterns.
await CSQ().setURLMaskingPatterns(patterns: ['pattern1', 'pattern2']);Parameters
Section titled Parameters-
patterns List<String>
A list of URL patterns to mask.
CSQ().collectFlutterError()
Section titled CSQ().collectFlutterError()Experience Analytics | Added in: 1.0.0
Sends a report of an error caught by the Flutter framework.
Typically used by assigning it to FlutterError.onError:
FlutterError.onError = (details) { CSQ().collectFlutterError(details: details);};Parameters
Section titled Parameters-
details FlutterErrorDetails
The Flutter error information.
-
presentErrorDetails bool (optional)
Whether to print the error details in the console. Defaults to
true.
CSQ().collectError()
Section titled CSQ().collectError()Experience Analytics | Added in: 1.0.0
Sends a report of a caught error.
Typically used inside a runZonedGuarded error handler:
runZonedGuarded(() { // your app code}, (error, stackTrace) { CSQ().collectError(error: error, stackTrace: stackTrace);});Parameters
Section titled Parameters-
error Object
The error object that was caught.
-
stackTrace StackTrace
The associated stack trace.
CSQ().sendUserIdentifier()
Section titled CSQ().sendUserIdentifier()Experience Analytics | Added in: 1.0.0
Associate a user identifier with the session. This identifier is immediately hashed so no Personal Data can ever be accessed.
await CSQ().sendUserIdentifier(userIdentifier: 'any_identifier');Parameters
Section titled Parameters-
userIdentifier String
The user identifier to track. Should be max 100 characters long.
Personal Data/Masking
Section titled Personal Data/MaskingCSQMask
Section titled CSQMask1.0.0
Applies masking rules to its descendants. Use this widget to mask sensitive content such as personal information, passwords, or any data you don't want collected.
CSQMask( config: const CSQMaskingConfig( maskTexts: true, maskImages: true, maskTextFields: true, maskInteractions: true, ), child: const Text('Sensitive content'),)Parameters
Section titled Parameters-
config CSQMaskingConfig
The masking configuration.
maskTexts bool (optional)
Mask widgets that render text (for example
Text,RichText).maskTextFields bool (optional)
Mask text input widgets (for example
TextField,TextFormField).maskImages bool (optional)
Mask image widgets (for example
Image).maskSvgImages bool (optional)
Mask SVG images.
maskCharts bool (optional)
Mask
fl_chartwidgets.maskCustomPaints bool (optional)
Mask
CustomPaintwidgets.maskInteractions bool (optional)
Prevent user interactions from being captured.
-
child Widget
The widget whose descendants will be masked.
SDK Initialisation and Management
Section titled SDK Initialisation and ManagementCSQ().start()
Section titled CSQ().start()1.0.0
Start the SDK. Should be called as early as possible in the app's lifecycle.
// DXA only (default):await CSQ().start();
// Product Analytics with environment ID:await CSQ().start( startConfig: StartConfig.withEnvironmentId( id: 'YOUR_ENVIRONMENT_ID', options: ProductAnalyticsOptions( enableInteractionsAutocapture: true, ), ),);
// Product Analytics with data source ID:await CSQ().start( startConfig: StartConfig.withDatasourceId( id: 'YOUR_DATASOURCE_ID', ),);Parameters
Section titled Parameters-
startConfig StartConfig (optional)
The SDK start configuration. Defaults to
StartConfig.dxa().StartConfig.dxa()
Experience Analytics only (default).
StartConfig.withEnvironmentId(id, options)
Product Analytics with environment ID.
StartConfig.withDatasourceId(id, options)
Product Analytics with data source ID.
-
maskingConfig CSQMaskingConfig (optional)
Global Session Replay masking configuration. See
CSQMask.
CSQ().configureProductAnalytics()
Section titled CSQ().configureProductAnalytics()Product Analytics | Added in: 1.0.0
Deprecated. Use start() with a StartConfig parameter instead. This method will be removed in August 2026.
SDK configuration method for Product Analytics. Must be called before start().
await CSQ().configureProductAnalytics( environmentId: 'YOUR_ENVIRONMENT_ID', options: PRODUCT_ANALYTICS_INITIALIZATION_OPTIONS,);Parameters
Section titled Parameters-
environmentId String
Your Product Analytics environment ID.
-
options ProductAnalyticsOptions (optional)
Product Analytics initialization options.
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.
await CSQ().stop();CSQ().pauseTracking()
Section titled CSQ().pauseTracking()1.0.0
Pause all tracking features.
await CSQ().pauseTracking();CSQ().resumeTracking()
Section titled CSQ().resumeTracking()1.0.0
Resume all tracking features.
await CSQ().resumeTracking();Parameters
Section titled ParametersNo parameters.
Product Analytics initialization options
Section titled Product Analytics initialization optionsCSQ SDK options for Product Analytics passed to CSQ().configureProductAnalytics() or StartConfig.withEnvironmentId().
await CSQ().configureProductAnalytics( options: ProductAnalyticsOptions( ),);environmentId
Section titled environmentIdProduct Analytics Environment ID.
uploadInterval
Section titled uploadIntervalInterval at which event batches should be uploaded to the API. Defaults to 15 seconds.
baseUrl
Section titled baseUrlURI object specifying the base URI for the desired API endpoint. The SDK resolves paths using this base URI and ignores any pre-existing path elements.
captureVendorId
Section titled captureVendorIdWhether the vendor ID should be included in tracked events if made available by the device. Defaults to false.
captureAdvertiserId
Section titled captureAdvertiserIdWhether the advertiser ID should be included in tracked events if made available by the device. Defaults to false.
clearEventPropertiesOnNewUser
Section titled clearEventPropertiesOnNewUserWhether to clear event properties when a new user is created. Defaults to false.
disablePageviewAutocapture
Section titled disablePageviewAutocaptureWhether source pageview events will be auto-captured. Defaults to false.
disablePageviewTitleAutocapture
Section titled disablePageviewTitleAutocaptureDisable pageview title capture.
disableInteractionAutocapture
Section titled disableInteractionAutocaptureDisables autocapture of touch interactions.
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 to true.
Defaults to false.
enablePushNotificationBodyAutocapture
Section titled enablePushNotificationBodyAutocaptureWhether capture the body text of the notification where an interaction was performed. enablePushNotificationAutocapture must be to true.
Defaults to false.
messageBatchByteLimit
Section titled messageBatchByteLimitThe 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 Contentsquare Product Analytics. Setting a lower limit can help reduce network traffic in situations where bandwidth is limited. Defaults to 100.
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.
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.
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 uploaded in a given cycle.
Defaults to 5.
enableInteractionsAutocapture
Section titled enableInteractionsAutocaptureWhether to enable automatic capture of Flutter UI interactions. Defaults to false.
disableScreenviewForwardToDXA
Section titled disableScreenviewForwardToDXADisable forwarding of Product Analytics Pageviews to Experience Analytics.
disableScreenviewForwardToPA
Section titled disableScreenviewForwardToPADisable forwarding of Experience Analytics Screenviews to Product Analytics.