Track custom variables

Custom variables are additional information on the screen, the user or the session, sent within screenviews.

For example, they can include information on the current layout of a screen, like dark or light mode.

  • 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 custom variable is used to determine which custom variable to be kept. Only index value between 1 and 20 will be taken into account.
  • Every custom variable is composed of index, name and value.
  • If you are using the same index twice in a single 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 characters 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 variable 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.

To define and send a custom variable, you need to use the following implementation:

val customVar1 = CustomVar(
index = 1,
name = "CustomVarName1",
value = "CustomVarValue1"
)
val customVar2 = CustomVar(
index = 2,
name = "CustomVarName2",
value = "CustomVarValue2"
)
Contentsquare.send(
screenName = "ScreenName",
cvars = arrayOf(customVar1, customVar2)
)