---
title: Experience Analytics extension - iOS
description: Understand the benefits of upgrading to the CSQ SDK
source_url:
  html: https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/
  md: https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/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.

> **Note**
>
> Cette page est affichée en anglais car elle n'est pas disponible dans votre langue.

Use this page to set up the Mobile Experience Analytics extension for Contentsquare Product Analytics.

This will supercharge the Product Analytics platform with:

* Powerful Session Replay
* Heatmaps
* Analysis capabilities of Mobile API Errors and Crashes

This guide assumes that you have already implemented the [CSQ SDK for Product Analytics](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/).

## Enable the extension in the Product Analytics UI

1. In Product Analytics, navigate to **Account** > **Manage** > **Replays & Heatmaps**.

2. If this is your first time setting up Session Replay, select the checkbox to accept the terms and conditions.

3. Click **Add web or mobile app** to launch the setup wizard. There is one configuration per app.

4. Select **Mobile** as platform.

5. Give your app a name and choose a storage location (**US** or **EU**).

6. Set a sampling rate for how many sessions to record.

7. Configure replay settings:

   * **App ID**: enter the bundle ID of your app (for example, `com.companyname.appname`).
   * **Quality Settings**: choose the recording fidelity for Wi-Fi and Cellular connections. The default for both is Medium; keep Cellular equal to or lower than Wi-Fi.
   * **User Consent**: enable this if your app requires explicit opt-in before recording. See [Privacy docs](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/privacy/#opt-in) for the opt-in API.

8. Click **Save and Continue** to finish the wizard.

## Enable error and crash collection

Error and crash collection is managed separately from the setup wizard. Navigate to **Account** > **Manage** > **Replays & Heatmaps**, click **Edit** next to your app configuration, then scroll to the relevant section under **General Settings**:

* **Error Capture**: toggles for **API Errors** and **Custom Errors**.
* **Crashes Capture**: toggle for **Crashes**.

Click **Save** when finished.

## Session Replay masking

The Session Replay feature replays every interaction of your users with your app. To respect the user's right to privacy, the Contentsquare SDK:

* Masks everything by default
* Allows you to control which part of the user interface is collected via our [Masking rules](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#masking-rules)

> **Attention**
>
> **Privacy Manifest:** If you decide to use unmasked elements leading to collection of new data or use already collected data but for a different purpose, it is up to you to update the privacy practices described in your app manifest accordingly. Here are some common examples of data collected via unmasked Session Replay: Search history, Purchase history, Advertising data, etc. See [Types of data and purpose](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/privacy/) already described in the Contentsquare iOS SDK Privacy Manifest.
>
> Contentsquare is not intended nor designed to collect sensitive personal data (such as health, financial, or racial data). It is the customer's responsibility not to send any sensitive personal data to Contentsquare.

### Masking mechanisms

Masking depends on the type of element:

| Element Type | Masking Behavior |
| - | - |
| `UIKit.UIImage` and `SwiftUI.Image` | Image isn't collected, a placeholder is sent instead of the content; the "IMG" placeholder will be displayed in the frame of the element. |
| `UIKit.UILabel` and `UIKit.UITextView` | Text is replaced by "la" repeated as many times as needed to equal the original character count. White characters are preserved. For instance `the lazy fox` is collected as `lal lala ala`. All other visual properties are collected (text color, background color, alignment, etc.). |
| `UIKit.UITextField` | Same as `UIKit.UILabel` or `UIKit.UITextView` unless `isSecureTextEntry` is set to `true`. In this case all characters, including whitespaces are replaced with "•". |
| `SwiftUI.Text` | Element is replaced by a black rectangle. |
| All other types | No specific data is collected but all visual properties are collected: size, background color, corner radius, etc. |

If you think a specific element can reveal personal data from one of these properties mask it using one of the methods presented below.

An efficient way to check how a view is rendered in the Session Replay is to navigate to the desired view with the SDK running then use the quick replay link.

![](https://docs.contentsquare.com/_astro/ios-get-replay-link.tN1tVH-m_Z1EodDY.webp)

**Original vs Replay fully masked**

* UIKit

  ![](https://docs.contentsquare.com/_astro/uikit-sr-masked.4j5fWBpf_1wMYqm.webp)

* SwiftUI

  ![](https://docs.contentsquare.com/_astro/swiftui-sr-masked.vHtiPIlu_Z1zur8Q.webp)

### Masking rules

Masking rules can be applied in two ways:

1. **Through remote masking configuration in the CSQ Console (for admin users):** This is managed directly in the Console and takes effect for all sessions as soon as the app is restarted or brought to the foreground. See [How to customize masking rules from the Data Masking tab ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) in the Help Center.

2. **Using public masking APIs in the SDK (for mobile application developers):** These APIs require developer implementation and will be applied only after the mobile app has gone through its release cycle.

The SDK determines whether views, images, and texts are masked according to the following rules, ranked from highest to lowest priority. Once a rule is triggered, the state is set, and subsequent rules are not applied.

#### General rules

| Rules (highest to lowest priority) | Configured via |
| - | - |
| 1. The app or SDK version is fully masked | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 2. Remote Text or Image masking is defined | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 3. The screen is remotely masked | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 4. An [instance](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-instance) is specifically masked or unmasked | API |
| 5. A [parent](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#masking-and-unmasking-behaviors-on-a-parent-view) is specifically masked or unmasked | API |
| 6. A [type](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-type) is masked or unmasked | API |
| 7. A parent [type](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-type) is masked or unmasked | API |
| 8. Remote Text or Image unmasking is defined | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 9. The screen is remotely unmasked | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 10. Otherwise the [default masking state](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#default-masking) is applied | API |

#### Text input fields rules

`UIKit.UITextField`, `UIKit.UITextView` and `SwiftUI.TextField` text inputs follow specific rules as the risk of leaking personal data is higher with these elements:

| Rules (highest to lowest priority) | Configured via |
| - | - |
| 1. The app or SDK version is fully masked | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 2. Remote Text inputs masking is defined | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 3. The screen is remotely masked | [Data Masking tab in the CSQ Console ↗](https://support.contentsquare.com/hc/en-us/articles/37271848716561-How-to-customize-masking-rules-from-the-Data-Masking-tab-Apps) |
| 4. An [instance](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-instance) is specifically masked or unmasked | API |
| 5. A [type](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-type) is masked or unmasked | API |
| 6. Otherwise a text input field remains masked | default |

> **Note**
>
> Default masking, parent masking, and remote screen unmasking don't change the masking state of text inputs.

#### Screen masking scope

Remote screen masking applies to the content of the screen only, that is the views of the matching view controller. It doesn't apply to the navigation bar, the tab bar, or any other element owned by a parent container controller. If these elements show sensitive content, for example a navigation title that contains a user name, mask them explicitly with [`mask(view:)`](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-instance), such as `mask(view: navigationController.navigationBar)`.

Remote screen masking matches on the screen name. Enable native autocapture with `.enableNativeAutocapture: true` in `CSQ.start` so that UIKit screens are named automatically. For SwiftUI screens, set a stable name with the `csqScreenName` view modifier. See [Customize autocaptured screen names](https://docs.contentsquare.com/en/csq-sdk-ios/product-analytics/customize-autocaptured-screen-names/).

### Public masking APIs

#### Default masking

All iOS views and subclasses of `UIView` are fully masked by default. Change the default masking state with:

```swift
/// Change the masking state of all types of views.
/// - Parameter mask: true restores the default masking state.
///                   false unmasks every type of views.
static func setDefaultMasking(_ mask: Bool)
```

> **Note**
>
> Setting the default masking state to `false` does not affect `UITextField`, `SwiftUI.TextField` and `WKWebView`.

#### Masking/Un-masking by instance

* UIKit

  Use `mask(view:)` and `unmask(view:)` methods to mask or unmask a specific view instance. Masking is applied recursively to all subviews unless specified otherwise (cf. [Masking and Unmasking behaviors on a parent view](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#masking-and-unmasking-behaviors-on-a-parent-view)).

  **Following the previous example on un-masking `UIButtons`:** you are in default masking, the `UIButton` are unmasked but a screen shows a button, `myButton`, that contains sensitive information. You can mask it with `mask(view: myButton)`.

* SwiftUI

  Mask or unmask a SwiftUI `View` instance by using the following view modifier. Masking is applied recursively to all subviews unless specified otherwise (cf. [Masking and Unmasking behaviors on a parent view](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#masking-and-unmasking-behaviors-on-a-parent-view)).

  ```swift
  @ViewBuilder
  func csMasking(_ shouldMask: Bool) -> some View
  ```

#### Masking/Un-masking by type

Although the SDK allows masking elements by type for convenience but it isn't the recommended masking mechanism because it impacts all screens of your application.

Use this when you have a specific class for presenting user information or for displaying the user profile picture to make sure it always stays masked, for instance.

* UIKit

  Use `mask(viewsOfType:)` and `unmask(viewsOfType:)` methods if you want to handle a specific type, whether system or custom.

  **Example: un-masking `UIButtons`**: If default masking is set to true, and you don't want any button to be masked, call `unmask(viewsOfType: UIButton.self):` to specify that all instances of `UIButton` and its subclasses should not be masked.

* SwiftUI

  Mask or un-mask by type using following methods as needed:

  ```swift
  /// Masks or unmasks all text elements.
  ///
  /// The text elements are `Text` for SwiftUI and `UILabel` for UIKit
  static func maskTexts(_ mask: Bool)
  ```

  ```swift
  /// Masks or unmasks all image elements.
  ///
  /// The image elements are `Image` for SwiftUI and `UIImageView` for UIKit.
  static func maskImages(_ mask: Bool)
  ```

  ```swift
  /// Masks or unmasks all text input elements.
  ///
  /// The text input elements are `TextField`, `SecureField`, `TextEditor` for SwiftUI
  /// and `UITextField`, `UITextView` for UIKit.
  ///
  static func maskTextInputs(_ mask: Bool)
  ```

> **Attention**
>
> These APIs will also affect **UIKit masking**. You can use only these APIs and mask/unmask both UIKit and SwiftUI elements.

#### Masking and Unmasking behaviors on a parent view

##### UIKit

Masking is applied recursively to all children unless a specific rule has been applied to one of them. In this case, this rule also applies recursively.

**Examples**

Consider the following structure:

```plaintext
(parent view)
------------------------
|    "Parent Label"    |
|                      |
| (child view)         |
| -------------------- |
| |   "Child Label"  | |
| |                  | |
| -------------------- |
|                      |
------------------------
```

Here's how the masking rules applied affect the parent and child labels:

| Rules applied | Parent Label | Child Label |
| - | - | - |
| No rule applied | Masked | Masked |
| Parent view unmasked | Unmasked | Unmasked |
| Parent view unmasked and child view masked | Unmasked | Masked |
| Default masking = false | Unmasked | Unmasked |
| Default masking = false and parent view masked | Masked | Masked |

See [Masking rules](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#masking-rules).

**Unmasking an instance when its type is masked**

If you've masked `UILabel` types specifically or are in default masking, call `unmask(view: myLabel)` so that all `UILabel` **instances** are masked except `myLabel`.

**Mask an instance when its type is unmasked**

If you've unmasked the `UILabel` type specifically or are using default masking, call `mask(view: myLabel)` so that no `UILabel` is masked except `myLabel`.

### Implementation recommendations

* UIKit

  Masking operations should **always be performed before the target view is added to the window** to avoid any Personal Data leak.

  For instance, you can set up masking in the `didFinishLaunching` callback of your app or if you need to change masking behavior while your app is launched: this can be done in `loadView`, `viewDidLoad` or `viewWillAppear` if you use a `ViewController`.

* SwiftUI

  Masking operations should be done as early as possible.

  For masking [by type](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-type), in the setup of your app for instance.

  For masking [by instance](https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/#maskingun-masking-by-instance), in the body of your `View` by calling the `csMasking` modifier.

### Keeping track of what is masked

The SDK doesn't provide a list of what is currently masked, if you need to keep track, you probably will have to write your specific wrapper.

### Masking operations performance impact

Repeating the same operation has little to no impact. For example, you can call `unmask(viewsOfType: UIButton.self)` multiple times without impacting the SDK or your app performance.

### Controlled Exposure

> **Note**
>
> This feature is part of [Experience Monitoring ↗](https://contentsquare.com/platform/experience-monitoring/), which is only available on Enterprise plans or as an add-on to Pro plans. Contact your Customer Success Manager or [sales ↗](https://contentsquare.com/request-a-demo/) to learn more.

.

By default, Session Replay masks sensitive content so it never reaches Contentsquare. Controlled Exposure lets you choose specific views whose content is collected and encrypted before it leaves the device, instead of being masked. Authorized users can then see that content in Session Replay, while it stays protected for everyone else.

Use it only for views that display data you need to see in replays, such as an order confirmation or a delivery address.

#### Encrypt a view

* UIKit

  Use `CSQ.encrypt(view:)` to mark a view to be collected with its content, encrypted. It will show masked in Session Replay until authorized users decrypt it.

  ```swift
  CSQ.encrypt(view: deliveryAddressLabel)
  ```

* SwiftUI

  Use the `csqEncrypt()` view modifier to mark a SwiftUI `View` to be collected with its content, encrypted, rather than masked.

  ```swift
  Text(deliveryAddress)
    .csqEncrypt()
  ```

> **Note**
>
> Encryption only applies to views that display text, such as `UILabel`, `UITextField`, `UITextView`, or SwiftUI `Text`. Applying it to a container view has no effect on the views inside it.
>
> With UIKit, call `CSQ.encrypt(view:)` before you add the view to the view hierarchy.

#### Clear the encryption of a view

`CSQ.clearEncrypt(view:)` is only available for UIKit. Use it to remove the encryption mark set with `CSQ.encrypt(view:)`. Call it for reusable views contents, such as labels in `UITableViewCell` or `UICollectionViewCell`, so the encryption state doesn't carry over to new content.

```swift
CSQ.clearEncrypt(view: deliveryAddressLabel)
```


```json
{"@context":"https://schema.org","@type":"TechArticle","headline":"Experience Analytics extension","description":"Understand the benefits of upgrading to the CSQ SDK","url":"https://docs.contentsquare.com/fr/csq-sdk-ios/product-analytics/dxae-setup/","inLanguage":"en","dateModified":"2026-06-12T11:40:35+02:00","publisher":{"@type":"Organization","name":"Contentsquare","url":"https://www.contentsquare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://docs.contentsquare.com/#website","name":"Documentation technique Contentsquare","url":"https://docs.contentsquare.com/"}}
```