---
title: Track custom variables - iOS (classic)
description: Track custom variables with the Contentsquare iOS SDK
lastUpdated: 14 April 2026
source_url:
  html: https://docs.contentsquare.com/fr/ios/track-custom-variables/
  md: https://docs.contentsquare.com/fr/ios/track-custom-variables/index.md
---

> Documentation index: 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.

The latest CSQ SDK is here! Learn how to [upgrade your app](https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/upgrade-from-cs-sdk/).

Custom variables attach additional information about the screen, user, or session to screenview events. For example, they can include information on the current layout of a screen, like day/night mode.

Attention

**Note about Privacy Manifest:** If you decide to use Custom Variables to collect 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. See [Purpose of processing and categories of personal data collected](https://docs.contentsquare.com/en/ios/privacy/#purpose-of-processing-and-categories-of-personal-data-collected) already described in the Contentsquare iOS SDK Privacy Manifest.

## Defining custom variables

To define and send custom variables, follow this:

* Swift

  ```swift
  import ContentsquareModule


  let cvar1 = CustomVar(index: 1, name: "CustomVarName1", value: "CustomVarValue1")
  let cvar2 = CustomVar(index: 2, name: "CustomVarName2", value: "CustomVarValue2")


  Contentsquare.send(screenViewWithName: "ScreenName", cvars: [cvar1, cvar2])
  ```

  Attention

  For consistent analytics, use the same index/name pair values across your application:

  **Screen A**

  ```swift
  let cvar4 = CustomVar(index: 1, name: "hero_banner_type", value: "carousel")
  Contentsquare.send(screenViewWithName: "ScreenA", cvars: [cvar4])
  ```

  **Screen B**

  ```swift
  let cvar4 = CustomVar(index: 1, name: "hero_banner_type", value: "slider")
  Contentsquare.send(screenViewWithName: "ScreenB", cvars: [cvar4])
  ```

* Objective-C

  ```objective-c
  @import ContentsquareModule;


  CustomVar *cvar1 = [[CustomVar alloc] initWithIndex:1
                                          stringName:@"CustomVarName1"
                                          stringValue:@"CustomVarValue1"];
  CustomVar *cvar2 = [[CustomVar alloc] initWithIndex:2
                                          stringName:@"CustomVarName2"
                                          stringValue:@"CustomVarValue2"];


  [Contentsquare sendWithScreenViewWithName:@"ScreenName" cvars:@[cvar1, cvar2]];
  ```

  Attention

  For consistent analytics, use the same index/name pair values across your application:

  **Screen A**

  ```objective-c
  CustomVar *cvar4 = [[CustomVar alloc] initWithIndex:4
                                      stringName:@"hero_banner_type"
                                      stringValue:@"carousel"];


  [Contentsquare sendWithScreenViewWithName:@"ScreenA" cvars:@[cvar4]];
  ```

  **Screen B**

  ```objective-c
  CustomVar *cvar4 = [[CustomVar alloc] initWithIndex:4
                                  stringName:@"hero_banner_type"
                                  stringValue:@"slider"];


  [Contentsquare sendWithScreenViewWithName:@"ScreenB" cvars:@[cvar4]];
  ```

## Limits

### On the server side

* It is possible to save up to 20 distinct custom variables per screenview. If more are received, only the first 20 custom variables, based on their `index` value, will be kept.
* The `index` value of the custom variable is used to determine which custom variables to be kept. Only `index` value between 1 and 20 will be taken into account.

### On the SDK side

* Every custom variable is composed of `index`, `name` and `value`.
* If you are using the same `index` twice in the same screen, only the first (`name`, `value`) pair associated with the `index` will be kept.
* In case `name`(max. 512 characters) or `value`(max. 255 characters) maximum character length is reached, the SDK will automatically trim the exceeding characters.
* If `name` or `value` are empty, the SDK will instead send the literal string `"cs-empty"`.
* Use a consistent index for a given custom var within an application — for instance, if the "screen layout" is collected with an `index` of 3, use the slot 3 for this information on every screen of the application.
