Track custom variables
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 implementation:
import 'package:contentsquare/csq.dart';
final customVar1 = CustomVar( index: 1, name: 'customName_1', value: 'customValue_1',);
final customVar2 = CustomVar( index: 2, name: 'customName_2', value: 'customValue_2',);
CSQ().trackScreenview( screenName: 'myAwesomeScreenName', customVars: [customVar1, customVar2],);Limits
Section titled LimitsOn the server side
Section titled On the server side- A maximum of 20 distinct custom variables per screenview can be stored. If more are received, only the first 20 custom variables, based on their
indexvalue, will be retained. - The
indexvalue of the custom variable determines which ones will be retained. Only index values from 1 to 20 (inclusive) will be considered.
On the SDK side
Section titled On the SDK side- Every custom variable is composed of
index,nameandvalue. - If the same
indexis used twice in the same screen, only the first (name,value) pair associated with theindexwill be kept. - A maximum of 20 custom variables can be stored on the same screenview.
- If the maximum character length is reached for
name(512 characters) orvalue(255 characters), the SDK will automatically truncate the additional characters automatically. - If
nameorvalueare empty, the SDK will instead send the literal string"cs-empty". - Maintain a consistent index for a given custom variable throughout the application. For example, if the "screen layout" is collected with an
indexof 3, use the slot 3 for this information on every screen of the application.