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()
[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.
CSQ.optOut()
[CSQ optOut];
Parameters
Section titled ParametersNo parameters.
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)
[CSQ identify:@"userIdentity"];
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.userIDlet userID = CSQ.metadata.userID
NSString *userID = [[CSQ metadata] userID];
CSQ.metadata.sessionID
Section titled CSQ.metadata.sessionIDlet sessionID = CSQ.metadata.sessionID
NSString *sessionID = [[CSQ metadata] sessionID];
CSQ.metadata.projectID
Section titled CSQ.metadata.projectIDlet projectID = CSQ.metadata.projectID
NSString *projectID = [[CSQ metadata] projectID];
CSQ.metadata.environmentID
Section titled CSQ.metadata.environmentIDlet environmentID = CSQ.metadata.environmentID
NSString *environmentID = [[CSQ metadata] environmentID];
CSQ.metadata.sessionReplayURL
Section titled CSQ.metadata.sessionReplayURLlet sessionReplayURL = CSQ.metadata.sessionReplayURL
NSString *sessionReplayURL = [[CSQ metadata] sessionReplayURL];
CSQ.metadata.identity
Section titled CSQ.metadata.identitylet identity = CSQ.metadata.identity
NSString *identity = [[CSQ metadata] identity];
Parameters
Section titled ParametersNo parameters.
CSQ.metadata.onChange()
Section titled CSQ.metadata.onChange()1.0.0
Trigger a callback whenever user information is updated.
CSQ.metadata.onChange { information in// Handle information change}
[[CSQ metadata] onChange:^(Information *information) {// Handle information change}];
Parameters
Section titled Parameters-
information Function
Identity to be associated with the current user.
Logging
Section titled LoggingCSQ.debug.logLevel
Section titled CSQ.debug.logLevel1.0.0
Gets or sets the current log level.
CSQ.debug.logLevel = .debug
[[CSQ debug] setLogLevel:CSQLogLevelDebug];
Parameters
Section titled Parameters-
level Enum (CSQ.Log.Level)
Possible values:
none
,trace
,debug
,info
,warn
,error
, orimportant
.
CSQ.debug.logChannel()
Section titled CSQ.debug.logChannel()1.0.0
Gets or sets the LogChannel
to which send log messages.
CSQ.debug.setLogChannel(LogChannel)
[[CSQ debug] setLogChannel:customLogChannel];
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 an array of DynamicVar
objects, each representing a key-value pair that is scoped to the session.
let var1 = DynamicVar(key: "key1", value: "value1")let var2 = DynamicVar(key: "key2", value: "value2")
CSQ.addDynamicVar([var1, var2])
DynamicVar *var1 = [[DynamicVar alloc] initWithKey:@"key1" value:@"value1"];DynamicVar *var2 = [[DynamicVar alloc] initWithKey:@"key2" value:@"value2"];
[CSQ addDynamicVar:@[var1, var2]];
Parameters
Section titled Parameters-
DynamicVar NSObject
The dynamic variable
key String (<= 512 chars)
Dynamic variable key
value Uint32
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([Property])
[CSQ addUserProperties:@{@"propertyKey": @"propertyValue"}];
Parameters
Section titled Parameters-
properties [Property]
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([Property])
[CSQ addEventProperties:@{@"propertyKey": @"propertyValue"}];
Parameters
Section titled Parameters-
properties [Property]
A map of event properties.
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)
[CSQ removeEventProperty:@"propertyKey"];
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 TrackingUIScrollView.excludeFromExposureMetrics()
Section titled UIScrollView.excludeFromExposureMetrics()Experience Analytics | Added in: 1.0.0
Exclude a scrollable view or subclass from Exposure Metric computations.
UIScrollView.excludeFromExposureMetrics(UIScrollView)
[UIScrollView excludeFromExposureMetrics:scrollView];
Parameters
Section titled Parameters-
UIScrollView Class
See https://developer.apple.com/documentation/uikit/uiscrollview ↗
CSInApp
Section titled CSInAppCSQ.handle()
Section titled CSQ.handle()Experience Analytics | Added in: 1.0.0
Allows the Contentsquare SDK to monitor CS in-app features activation through a custom URL scheme.
CSQ.handle(url: URL)
[CSQ handleWithURL:[NSURL URLWithString:@"https://example.com"]];
Parameters
Section titled Parameters-
url Struct
See https://developer.apple.com/documentation/foundation/url ↗
CSQ.csInApp
Section titled CSQ.csInAppExperience Analytics | Added in: 1.0.0
Boolean to manually activate or deactivate in-app features.
When CSQ.csInApp = true
, the in-app function is activated automatically at app start.
CSQ.csInApp = true
CSQ.csInApp = YES;
Parameters
Section titled ParametersNo parameters.
Interoperability
Section titled InteroperabilityCSQ.registerWebView()
Section titled CSQ.registerWebView()1.0.0
Register a webview for tracking.
CSQ.registerWebView(webView: WKWebView())
[CSQ registerWebView:[[WKWebView alloc] init]];
Parameters
Section titled Parameters-
webView WKWebView
The webview to register for tracking.
CSQ.unregisterWebView()
Section titled CSQ.unregisterWebView()1.0.0
Unregister a webview for tracking.
CSQ.unregisterWebView(webView: WKWebView())
[CSQ unregisterWebView:webView];
Parameters
Section titled Parameters-
webView WKWebView
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.
let transaction = Transaction(id: "transactionId", total: 100.0)CSQ.trackTransaction(transaction)
Transaction *transaction = [[Transaction alloc] initWithId:@"transactionId" total:100.0];[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: "ScreenName", cvars: [CustomVar(key: "key", value: "value")])
[CSQ trackScreenview:@"ScreenName" cvars:@[[CustomVar customVarWithKey:@"key" value:@"value"]]];
Parameters
Section titled Parameters-
name String
The name of the screen.
-
cvars CustomVar[] (optional)
An array of custom variables to attach to the screen view.
key String (<= 512 chars)
Custom variable key
value Uint32
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: [String, PropertyValue]?)
[CSQ trackEventWithName:@"EventName" properties:@{@"propertyKey": @"propertyValue"}];
Parameters
Section titled Parameters-
name String
The name of the event to be tracked.
-
properties Map<String, PropertyValue> (optional)
Optional properties to associate with the event.
key String (<= 512 chars)
Property name
value Uint32
Property value
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)
[CSQ triggerSurvey: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 completed[CSQ 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)
[CSQ setUrlMaskingPatterns:@[@"pattern1", @"pattern2"]];
Parameters
Section titled Parameters-
patterns Array<String>
A list of URL patterns to mask.
CSQ.onCrashReporterStart()
Section titled CSQ.onCrashReporterStart()Experience Analytics | Added in: 1.0.0
Trigger a callback when the Contentsquare Crash Reporter is initialized.
CSQ.onCrashReporterStart()
[CSQ onCrashReporterStart];
Parameters
Section titled ParametersNo parameters.
CSQ.trackNetworkMetric()
Section titled CSQ.trackNetworkMetric()Experience Analytics | Added in: 1.0.0
Track network metrics.
CSQ.trackNetworkMetric(NetworkMetric)
NetworkMetric *networkMetric = [[NetworkMetric alloc] initWithURL:@"https://example.com" duration:1.5];[CSQ trackNetworkMetric:networkMetric];
Parameters
Section titled Parameters-
networkMetric object
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(UIView)
[CSQ ignoreInteractions:view];
Parameters
Section titled Parameters-
UIView TODO:?
UIView.csqIgnoreInteractions
Section titled UIView.csqIgnoreInteractionsUIKit | Added in: 1.0.0
Ignore interactions for a specific view.
UIView.csqIgnoreInteractions
view.csqIgnoreInteractions = YES;
Parameters
Section titled ParametersNo parameters.
View.csqIgnoreInteractions
Section titled View.csqIgnoreInteractionsExperience Analytics SwiftUI | Added in: 1.0.0
Ignore interactions for a specific view.
View.csqIgnoreInteractions(shouldIgnore: Bool)
[View csqIgnoreInteractions:YES];
Parameters
Section titled Parameters-
shouldIgnore Bool
Whether to ignore interactions.
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(Bool masked)
[CSQ setDefaultMasking:YES];
Parameters
Section titled Parameters-
masked Bool
The masking state to be set.
CSQ.mask(UIView)
Section titled CSQ.mask(UIView)1.0.0
Mask a view’s content.
CSQ.mask(UIView)
[CSQ mask:view];
Parameters
Section titled Parameters-
UIView UIView
The view which content will be masked.
UIView.csqMaskContents
Section titled UIView.csqMaskContentsUIKit | Added in: 1.0.0
Mask the content of a view.
UIView.csqMaskContents
view.csqMaskContents = YES;
Parameters
Section titled ParametersNo parameters.
View.csqMaskContents
Section titled View.csqMaskContentsSwiftUI | Added in: 1.0.0
Mask the content of a view.
View.csqMaskContents(enable: Bool)
[View csqMaskContents:YES];
Parameters
Section titled Parameters-
enable Bool
Whether to mask the content of the view.
CSQ.mask(viewsOfType: UIView.Type
)
Section titled CSQ.mask(viewsOfType: UIView.Type)Experience Analytics | Added in: 1.0.0
Mask content for views of a specific type.
CSQ.mask(viewsOfType: UIView.Type)
[CSQ maskViewsOfType:[UIView class]];
Parameters
Section titled Parameters-
viewsOfType UIView.Type
The class type of the view whose content will be masked.
CSQ.unmask()
Section titled CSQ.unmask()1.0.0
Unmask content for views of a specific type.
CSQ.unmask(viewsOfType: UIView.Type)
[CSQ unmaskViewsOfType:[UIView class]];
Parameters
Section titled Parameters-
viewsOfType UIView.Type
The class type of the view whose content will be unmasked.
CSQ.maskTexts()
Section titled CSQ.maskTexts()1.0.0
Mask text.
CSQ.maskTexts(mask: Bool)
[CSQ maskTexts:YES];
Parameters
Section titled Parameters-
mask Bool
Whether to mask text.
CSQ.maskImages()
Section titled CSQ.maskImages()Experience Analytics | Added in: 1.0.0
Mask images.
CSQ.maskImages(mask: Bool)
[CSQ maskImages:YES];
Parameters
Section titled Parameters-
mask Bool
Whether to mask images.
CSQ.maskTextInputs()
Section titled CSQ.maskTextInputs()Experience Analytics | Added in: 1.0.0
Mask text input fields.
CSQ.maskTextInputs(mask: Bool)
[CSQ maskTextInputs:YES];
Parameters
Section titled Parameters-
mask Bool
Whether to mask text inputs.
UIView.csqIgnoreInteractionsDefault
Section titled UIView.csqIgnoreInteractionsDefaultUIView.csqIgnoreInteractionsDefault = true
[UIView setCsqIgnoreInteractionsDefault:YES];
UIView.csqIgnoreInnerHierarchy
Section titled UIView.csqIgnoreInnerHierarchyProduct Analytics UIView | Added in: 1.0.0
If set on a view or view controller, all touches inside that control will be attributed to it rather than child views. This can be helpful in blocking sensitive parts of an interaction and keeping implementation details out of a view hierarchy. For example, Contentsquare uses this property internally to suppress inner touches on UIDatePicker
.
let view = UIView()view.csqIgnoreInnerHierarchy = true
UIView *view = [[UIView alloc] init];view.csqIgnoreInnerHierarchy = YES;
UIView.csqIgnoreInnerHierarchyDefault
Section titled UIView.csqIgnoreInnerHierarchyDefaultProduct Analytics UIView | Added in: 1.0.0
This has the same effect as csqIgnoreInnerHierarchy
but is applied at the class level through an overridable class property. If defined, csqIgnoreInnerHierarchy
can still be used to override an individual instance.
let view = UIView()view.csqIgnoreInnerHierarchyDefault = true
UIView *view = [[UIView alloc] init];view.csqIgnoreInnerHierarchyDefault = YES;
SDK Initialisation and Management
Section titled SDK Initialisation and ManagementCSQ.configureProductAnalytics()
Section titled CSQ.configureProductAnalytics()Product Analytics | Added in: 1.0.0
SDK configuration method for Product Analytics. Must be called before start()
.
CSQ.configureProductAnalytics( environmentID: String, additionalOptions: [ PRODUCT_ANALYTICS_INITIALIZATION_OPTIONS ] )
[CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID" additionalOptions:@{PRODUCT_ANALYTICS_INITIALIZATION_OPTIONS}];
Parameters
Section titled Parameters-
environmentID String
Your Product Analytics environment ID.
-
PRODUCT_ANALYTICS_INITIALIZATION_OPTIONS [Option : Any]
Product Analytics initialization options.
CSQ.start()
Section titled CSQ.start()1.0.0
Manually start the SDK.
CSQ.start();
[CSQ start];
Parameters
Section titled ParametersNo parameters.
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];
Parameters
Section titled ParametersNo parameters.
CSQ.state
Section titled CSQ.state1.0.0
Return the state of the SDK:
running
stopped
paused
Product Analytics initialization options
Section titled Product Analytics initialization optionsCSQ SDK options for Product Analytics passed to CSQ.configureProductAnalytics()
.
CSQ.configureProductAnalytics( additionalOptions: [ ])
additionalOptions:@{ }];
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 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.
disablePageviewTitleCapture
Section titled disablePageviewTitleCaptureDisable pageview title capture.
disableInteractionAutocapture
Section titled disableInteractionAutocaptureDisables autocapture of touch events on UIKit, Android Views, and React Native.
enableUIKitAutocapture
Section titled enableUIKitAutocaptureEnable Product Analytics iOS View events.
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.
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 Heap.
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.
disableScreenviewForwardToDXA
Section titled disableScreenviewForwardToDXADisable forwarding of Product Analytics Pageviews to Experience Analytics.
disableScreenviewForwardToPA
Section titled disableScreenviewForwardToPADisable forwarding of Experience Analytics Screenviews to Product Analytics.