Sending dynamic vars
General principles
Section titled General principlesDynamic vars are additional information on the session that can be used to segment users.
For example, they can include information on the A/B Test variations displayed to the current user.
Unlike custom vars, dynamic vars can be sent at any time during a session and do not require to send a pageview.
Limits
Section titled LimitsOn the server side
Section titled On the server sideIt is possible to save up to 40 distinct dynamic variables per pageview. If more are received, only the first 40 distinct keys will be kept.
If multiple dynamic variables using the same key are fired per pageview, only the last value associated with the key will be kept
On the Tracking Tag side
Section titled On the Tracking Tag sideEvery dynamic variable being composed of a pair of key (max. 512 characters) and value (max. 255 characters string or integer from 0-4294967296). The key and value are truncated by the Tracking Tag before they are sent.
Defining dynamic vars
Section titled Defining dynamic varsTo define and send a dynamic var at once, use the trackDynamicVariable
command:
Allowed values are number
or string
— there are specific capabilities for each in the Contentsquare app:
- For values of type number, you can use operators (more than, less than, etc.).
- For values of type string, auto-completion and regular expressions are available.
Verifying the sending of dynamic vars
Section titled Verifying the sending of dynamic varsOur Contentsquare Tracking Setup Assistant Chrome Extension ↗ displays each dynamic var sent.
Inspecting the payload
Section titled Inspecting the payloadIf you can’t use our Chrome extension, use the _cs_debug
cookie.
-
From the browser console, run this command to create the cookie:
-
Reload the page.
-
In the Network tab, search for
dvar
, select the request, and check the value of thedv
parameter.
Checking the requests
Section titled Checking the requestsTo check the actual request that is sent for each dynamic vars package (several dynamic vars pushed at the same time bundled together in a single network request), follow GET requests sent to //c.contentsquare.net/dvar
, with these parameters.
Name | Description | Type |
---|---|---|
dv | Dynamic vars (compressed) | String |
pid | Project ID | Integer |
r | A random digit to avoid request caching | Integer |
uu | Unique user ID | String |
pn | Page number (each pageview increments of 1) | Integer |
sn | Session number | Integer |