---
title: SDK API reference - React Native
description: SDK commands reference including signature, parameter descriptions, and examples
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/
  md: https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/index.md
---

> ## Documentation index
> Fetch the complete documentation index at: 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:** `6.0.0`

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

Call [`optIn`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqoptin) after [`start`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqstart).

```javascript
CSQ.optIn();
```

### CSQ.optOut

**Added in:** `6.0.0`

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

```javascript
CSQ.optOut();
```

### CSQ.identify

Product Analytics | **Added in:** `6.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.

> **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`.

```javascript
CSQ.identify("user_identity");
```

#### Parameters

* `identity`  *string (<= 100 chars)*  

  Identity to be associated with the current user.

### CSQ.resetIdentity

**Added in:** `6.0.0`

If the user was previously identified with [`identify()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqidentify), this creates a new unidentified user and session. This is technically similar to calling [`optOut()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqoptout) then [`optIn()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqoptin).

This should be called only after Product Analytics is configured and the SDK started.

```javascript
CSQ.resetIdentity();
```

### CSQ.sendUserIdentifier

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

Associate the user identifier to the session.

```javascript
CSQ.sendUserIdentifier("any_identifier")
```

#### Parameters

* `userIdentifier`  *string*  

  The user identifier to track. Should be max 100 characters long.

### CSQ.onMetadataChange

**Added in:** `6.0.0`

Get all the information related to the user and project. Refer to the [`CSQMetadata`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqmetadata) object.

```javascript
CSQ.onMetadataChange(callback: (metadata: CSQMetadata) => void) => {
  // Handle metadata change
});
```

#### Parameters

* `callback`  *(metadata: CSQMetadata) => void*  

  Callback function triggered when metadata changes.

### `CSQMetadata`

`CSQMetadata` object contains information related to the user and project.

```javascript
interface CSQMetadata {
    userID: string | null;
    sessionID: string | null;
    identity: string | null;
    environmentID: string | null;
    projectID: string | null;
    sessionReplayURL: string | null;
}
```

#### `userID`

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

#### `sessionID`

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

#### `projectID`

Project identifier for Experience Analytics.

#### `environmentID`

Environment identifier for Product Analytics.

#### `sessionReplayURL`

URL of current Session Replay.

#### `identity`

Identity associated with the user by calling [`identify()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqidentify).

## Property Tracking

### CSQ.addDynamicVar

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

Adds dynamic variables to the session properties. This method allows you to pass a `key` and a `value` parameters, representing a key-value pair that is scoped to the session. You can also add, as a last parameter, a function that we will call so you can handle it gracefully

```javascript
CSQ.addDynamicVar("key1", "value1")
CSQ.addDynamicVar("key2", 2, (errorObject) => {
  console.log(errorObject.toString());
});
```

#### Parameters

* `key`  *string*  

  Dynamic variable key

* `value`  *string*  

  Dynamic variable value

* `callback`  *(error: Error) => void (optional)*  

  Optional callback function to handle errors.

### CSQ.addUserProperties

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

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

```javascript
CSQ.addUserProperties({
  propertyKey: "propertyValue",
});
```

#### Parameters

* `properties`  *Record\<string, PropertyValue*  

  A dictionary of user properties. `PropertyValue` can be `number`, `string`, `boolean`, `bigint`

### CSQ.addEventProperties

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

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

```javascript
CSQ.addEventProperties({
  propertyKey: "propertyValue",
});
```

#### Parameters

* `properties`  *Record\<string, PropertyValue>*  

  A dictionary of event properties. `PropertyValue` can be `number`, `string`, `boolean`, `bigint`

### CSQ.removeEventProperty

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

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

```javascript
CSQ.removeEventProperty("propertyKey")
```

#### Parameters

* `name`  *string*  

  The key of the property to remove.

### CSQ.clearEventProperties

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

Removes all event-wide properties.

```javascript
CSQ.clearEventProperties()
```

## CSInApp

### CSQ.handleUrl

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

Allows the Contentsquare SDK to monitor CS in-app features activation through a custom URL scheme.

For more details check our [CSInApp documentation](https://docs.contentsquare.com/en/csq-sdk-react-native/experience-analytics/in-app-features/).

```javascript
CSQ.handleUrl("sample_url")
```

#### Parameters

* `urlString`  *string | null | undefined*  

  The URL handled by [React Native Linking API ↗](https://reactnative.dev/docs/linking).

## Interoperability

### \<CSQWebView>

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

Allows Contentsquare SDK to track webviews.

```javascript
<CSQWebView>
  <WebView
    source={{
      uri: "https://test-url.com",
    }}
  />
</CSQWebView>
```

#### Parameters

* `children`  *ReactElement*  

  The webview to register for tracking. CSQWebView supports [react-native-webview ↗](https://github.com/react-native-webview/react-native-webview).

## Event Tracking

### CSQ.trackTransaction

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

Send a transaction.

```javascript
CSQ.trackTransaction(10, Currency.EUR, "transactionId");
```

#### Parameters

* `value`  *number*  

  The monetary value of the transaction.

* `currency`  *Currency | string*  

  The ISO 4217 currency code of the transaction.

* `transactionId`  *string | null (optional)*  

  An optional identifier for the transaction.

### CSQ.trackScreenview

**Added in:** `6.0.0`

Send a screen view with or without custom variables. Requires Experience Analytics to be started.

```javascript
CSQ.trackScreenview(name: "ScreenName", cvars: [{index: 0, key: "key", value: "value"}])
```

#### Parameters

* `name`  *String*  

  The name of the screen.

* `cvars`  *CustomVar\[] (optional)*  

  An array of custom variables to attach to the screen view.

  * `index`  *number*  

  * Custom variable index

  * `key`  *string (<= 512 chars)*  

  * Custom variable key

  * `value`  *string (<= 256 chars)*  

  * Custom variable value

### CSQ.trackEvent

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

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

```javascript
CSQ.trackEvent('event', { some_property: 100 });
```

#### Parameters

* `eventName`  *string*  

  The name of the event to be tracked.

* `properties`  *Record\<string, PropertyValue> (optional)*  

  Optional properties to associate with the event. `PropertyValue` can be `number`, `string`, `boolean`, `bigint` or array of these types.

## Logging

### CSQ.logToConsole

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

Enables logging to the console for Product Analytics events and diagnostics.

```javascript
CSQ.logToConsole();
```

### CSQ.setLogChannel

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

Sets the log channel for Product Analytics logging.

```javascript
import { LogChannel } from '@contentsquare/react-native-bridge';

CSQ.setLogChannel(LogChannel.LOG);
```

#### Parameters

* `logChannel`  *LogChannel*  

  The log channel to use. Available values:

  * `LogChannel.LOG`
  * `LogChannel.TRACE`
  * `LogChannel.DEBUG`
  * `LogChannel.INFO`
  * `LogChannel.WARN`
  * `LogChannel.ERROR`
  * `LogChannel.NONE`

### CSQ.setLogLevel

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

Sets the log level for Product Analytics logging.

```javascript
import { LogLevel } from '@contentsquare/react-native-bridge';

CSQ.setLogLevel(LogLevel.INFO);
```

#### Parameters

* `logLevel`  *LogLevel*  

  The log level to use. Available values:

  * `LogLevel.TRACE`
  * `LogLevel.DEBUG`
  * `LogLevel.INFO`
  * `LogLevel.WARN`
  * `LogLevel.ERROR`
  * `LogLevel.NONE`

## Error tracking

### CSQ.setUrlMaskingPatterns

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

Sets URL masking patterns.

```javascript
CSQ.setUrlMaskingPatterns(["pattern1", "pattern2"])
```

#### Parameters

* `patterns`  *string\[]*  

  A list of URL patterns to mask.

### CSQ.triggerNativeCrash

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

Trigger a native crash for testing purposes.

```javascript
CSQ.triggerNativeCrash()
```

## Session Replay

### CSQ.startSessionReplay

**Added in:** `6.3.0`

Starts Session Replay. Use this when you have set [`sessionReplayAutoStart`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#sessionreplayautostart) to `false` to manually control when Session Replay starts. Calling this method does not force Session Replay collection — it enables the module to begin evaluating sampling rules.

```javascript
import { CSQ } from "@contentsquare/react-native-bridge";

CSQ.startSessionReplay();
```

### CSQ.stopSessionReplay

**Added in:** `6.3.0`

Stops Session Replay collection. Any data collected before this call is preserved and uploaded according to the SDK upload schedule.

```javascript
import { CSQ } from "@contentsquare/react-native-bridge";

CSQ.stopSessionReplay();
```

### CSQ.triggerReplayForCurrentSession

**Added in:** `6.4.0`

Triggers Session Replay for the entire current session, with the parameter name as "ETR event".

```javascript
import { CSQ } from "@contentsquare/react-native-bridge";

CSQ.triggerReplayForCurrentSession("ETR event");
```

### CSQ.triggerReplayForCurrentScreen

**Added in:** `6.4.0`

Triggers Session Replay for the entire current screen, with the parameter name as "ETR event".

```javascript
import { CSQ } from "@contentsquare/react-native-bridge";

CSQ.triggerReplayForCurrentScreen("ETR event");
```

## Personal Data/Masking

### CSQ.setDefaultMasking

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

Set the default masking state. All Views are fully masked by default.

```javascript
CSQ.setDefaultMasking(true)
```

#### Parameters

* `masked`  *Bool*  

  The default masking state to be set.

### `<CSQMask>`

**Added in:** `6.0.0`

Allows to mask content for Session Replay and suppress events for view inside `<CSQMask>` and all its children. By default, Session Replay masking is enabled, and event tracking is disabled.

```javascript
<CSQMask>
  <View>
    ...
  </View>
</CSQMask>
```

#### Props

* `isSessionReplayMasked`  *boolean*  

  The view which content will be masked.

* `ignoreTextOnly`  *boolean*  

  Product Analytics This will ignore text and accessibility labels inside the masked view for event tracking.

* `allowInnerHierarchy`  *boolean*  

  Product Analytics Allows the full hierarchy to be exposed, but without properties or text capture.

* `allowProps`  *boolean*  

  Product Analytics Allows property capture, but will exclude text-containing properties if the below options are omitted.

* `allowText`  *boolean*  

  Product Analytics Allows text capture. It can be used alongside `allowProps` to expose text-containing properties.

* `allowAccessibilityLabel`  *boolean*  

  Product Analytics Allows `accessibilityLabel` capture.

* `children`  *ReactElement*  

  The view which masking rules will be applied to.

##### `withCSQMask`

`withCSQMask` takes a component and returns a Higher Order Component (HOC) that wraps it. This component accepts the same arguments but has `<CSQMask>` already applied.

##### Props

* `WrappedComponent`  *ReactElement*  

  The component which masking rules will be applied to.

* `maskOptions`  *CSQMaskProps*  

  Masking options to be applied to the wrapped component.

- `isSessionReplayMasked`  *boolean*  

  The view which content will be masked.

- `ignoreTextOnly`  *boolean*  

  Product Analytics This will ignore text and accessibility labels inside the masked view for event tracking.

- `allowInnerHierarchy`  *boolean*  

  Product Analytics Allows the full hierarchy to be exposed, but without properties or text capture.

- `allowProps`  *boolean*  

  Product Analytics Allows property capture, but will exclude text-containing properties if the below options are omitted.

- `allowText`  *boolean*  

  Product Analytics Allows text capture. It can be used alongside `allowProps` to expose text-containing properties.

- `allowAccessibilityLabel`  *boolean*  

  Product Analytics Allows `accessibilityLabel` capture.

### `<CSQEncrypt>`

Experience Monitoring | **Added in:** `6.6.0`

Marks a `Text` or `TextInput` for Controlled Exposure: Session Replay collects it masked, as usual, and also unmasked but encrypted. Only available to Experience Monitoring customers.

```javascript
<CSQEncrypt>
  <Text>Order #A-1042</Text>
</CSQEncrypt>
```

#### Props

* `children`  *ReactElement*  

  The single `Text` or `TextInput` component to encrypt. If you pass more than one child, nothing is rendered. Any other type of child is rendered but not encrypted.

* `...viewProps`  *ViewProps*  

  Any `View` props, such as `style`, applied to the container rendered around the child.

## SDK Initialization and Management

### CSQ.configureProductAnalytics

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

> **Deprecated**
>
> `CSQ.configureProductAnalytics()` is deprecated since 6.3.0. Use `CSQ.start(StartConfig.withEnvironmentId(...))` to combine SDK configuration and initialization in a single call. See [`start`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqstart).

Product Analytics is now configured using the `options` parameter of [`start()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqstart).

### CSQ.start

**Added in:** `6.0.0`

Start and configure the SDK. Use `StartConfig` to specify the product configuration.

```javascript
import { CSQ, StartConfig } from '@contentsquare/react-native-bridge';

// Experience Analytics only (DXA)
CSQ.start(StartConfig.dxa());

// Product Analytics (Standalone)
CSQ.start(StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID"));

// Product Analytics (CSQ Experience Platform)
CSQ.start(StartConfig.withDataSourceId("YOUR_DATASOURCE_ID"));

// Product Analytics with options
CSQ.start(StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID", {
  enableRNAutocapture: true
}));
```

#### StartConfig

##### Parameters

* `StartConfig.dxa()`  *CSQConfig*  

  Start the SDK with Experience Analytics (DXA) only.

* `StartConfig.withEnvironmentId(id, options?)`  *CSQConfig*  

  Start the SDK with Product Analytics using an environment ID.

  * `id` *(string)* — Your Product Analytics environment ID.
  * `options` *(AnalyticsOptions, optional)* — Product Analytics [initialization options](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#product-analytics-initialization-options).

* `StartConfig.withDataSourceId(id, options?)`  *CSQConfig*  

  Start the SDK with Product Analytics using a data source ID (CSQ Experience Platform).

  * `id` *(string)* — Your CSQ Experience Platform data source ID.
  * `options` *(AnalyticsOptions, optional)* — Product Analytics [initialization options](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#product-analytics-initialization-options).

### CSQ.stop

**Added in:** `6.0.0`

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

```javascript
CSQ.stop();
```

### CSQ.pauseTracking

**Added in:** `6.0.0`

Pause all tracking features.

```javascript
CSQ.pauseTracking();
```

### CSQ.resumeTracking

**Added in:** `6.0.0`

Resume all tracking features.

```javascript
CSQ.resumeTracking();
```

## Product Analytics initialization options

CSQ SDK options for Product Analytics passed to [`start()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqstart).

```javascript
type AnalyticsOptions = {
  enableRNAutocapture?: boolean;
  disableInteractionAutocapture?: boolean;
  disablePageviewAutocapture?: boolean;
  baseUrl?: string; // EU: "https://mh.ba.contentsquare.net"; https://mh.bf.contentsquare.net (default)
  uploadInterval?: number;
  disableInteractionTextCapture?: boolean;
  disableInteractionAccessibilityLabelCapture?: boolean;
  sessionReplayAutoStart?: boolean;
  // Native specific options
  enablePushNotificationAutocapture?: boolean;
  enablePushNotificationTitleAutocapture?: boolean;
  enablePushNotificationBodyAutocapture?: boolean;
  enableViewAutocapture?: boolean;
  // iOS specific options
  disablePageviewTitleAutocapture?: boolean;
};
```

## React Native Product Analytics initialization options

### `enableRNAutocapture`

Enable React Native view autocapture. Defaults to false.

### `disableInteractionAutocapture`

Disables autocapture of touch events on React Native Views. Defaults to false.

### `disablePageviewAutocapture`

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

### `baseUrl`

The CSQ API endpoint to use:

* `https://mh.ba.contentsquare.net` — EU-hosted environments
* `https://mh.bf.contentsquare.net` — all other environments (default)

### `uploadInterval`

The interval, in milliseconds, between event uploads.

### `disableInteractionTextCapture`

Disables text capture for React Native interactions. Defaults to false.

### `disableInteractionAccessibilityLabelCapture`

Disables accessibility label capture for React Native interactions. Defaults to false.

### `sessionReplayAutoStart`

Whether the SDK starts Session Replay automatically when the SDK starts. When set to `false`, you must call [`CSQ.startSessionReplay()`](https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/#csqstartsessionreplay) to start Session Replay. Defaults to `true`.

## Native specific Product Analytics initialization options

### `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 to true. Defaults to false.

### `enablePushNotificationBodyAutocapture`

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

### `enableViewAutocapture`

Whether the SDK will auto capture UI interactions and source pageviews. Defaults to false.

## iOS specific Product Analytics initialization options

### `disablePageviewTitleAutocapture`

Disable pageview title capture.


```json
{"@context":"https://schema.org","@type":"TechArticle","headline":"SDK API reference","description":"SDK commands reference including signature, parameter descriptions, and examples","url":"https://docs.contentsquare.com/en/csq-sdk-react-native/product-analytics/command-reference/","inLanguage":"en","dateModified":"2026-11-02T14:14:39+01:00","publisher":{"@type":"Organization","name":"Contentsquare","url":"https://www.contentsquare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://docs.contentsquare.com/#website","name":"Contentsquare Technical Documentation","url":"https://docs.contentsquare.com/"}}
```