Track custom variables
Usage
Section titled UsageCustom variables are additional information on the page, the user or the session, and which can be used to create mappings.
For example, they can include information on the current layout of a screen, like dark or light mode.
Limits
Section titled LimitsOn the server side
Section titled 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
indexvalue, will be kept. - The
indexvalue of custom variable is used to determine which custom variable to be kept. Onlyindexvalue between 1 and 20 will be taken into account.
On the SDK side
Section titled On the SDK side- Every custom variable is composed of
index,nameandvalue. - If you are using the same
indextwice in a single screen only the first (name,value) pair associated with theindexwill be kept. - In case
name(max. 512 characters) orvalue(max. 255 characters) maximum characters length is reached, the SDK will automatically trim the exceeding characters. - If
nameorvalueare empty, the SDK will instead send the literal string"cs-empty". - Use a consistent
indexfor a given variable within an application - for instance, if the “screen layout” is collected with anindexof 3, use the slot 3 for this information on every screen of the application.
Defining custom variables
Section titled Defining custom variablesTo define and send custom variables, follow this:
val customVar1 = CustomVar(1, "CustomVarName1", "CustomVarValue1")val customVar2 = CustomVar(2, "CustomVarName2", "CustomVarValue2")
CSQ.trackScreenview("ScreenName", arrayOf(customVar1, customVar2))CustomVar customVar1 = new CustomVar(1, "CustomVarName1", "CustomVarValue1");CustomVar customVar2 = new CustomVar(2, "CustomVarName2", "CustomVarValue2");
CustomVar[] customVars = new CustomVar[] {customVar1, customVar2};
CSQ.trackScreenview("ScreenName", customVars);