Track custom variables
The latest CSQ SDK is here! Learn how to upgrade your app.
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.
Defining custom variables
Section titled Defining custom variablesTo define and send custom variables, follow this example:
import Contentsquare, { CustomVar } from "@contentsquare/react-native-bridge";
const cVar1: CustomVar = { index: 1, key: "CustomVarName1", value: "CustomVarValue1",};const cVar2: CustomVar = { index: 2, key: "CustomVarName2", value: "CustomVarValue2",};
Contentsquare.send("ScreenName", [cVar1, cVar2]);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 the custom variable is used to determine which custom variables to be kept. Onlyindexvalues 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 the same screen, only the first (name,value) pair associated with theindexwill be kept. - It is possible to save up to 20 custom vars on the same screenview.
- In case
name(max. 512 characters) orvalue(max. 255 characters) maximum character 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 index for a given custom var within an application — for instance, if the "screen layout" is collected with an
indexof 3, use the slot 3 for this information on every screen of the application.