Data storage
Last updated
Last updated
Commanders Act Data Storage is a cookie stored on the user’s browser.
When you create data storage in the Commanders Act interface, a cookie with the same name is stored on the visitor’s browser. Data storage allows you to make use of the data it contains. Its use is described in the next articles in this section.
Data storage is useful for continually storing data about a visitor from one page to the next, from one visit to the next or for a defined period of time up to one year.
It is a cookie that stores data and allows to use it afterwards in many ways. Its uses are detailed in other articles in this section.
Additional information
Data storage that you create in the interface are first-party cookies, which are cookies set for your site’s domain name.
You can use the function below to see the content of data storage created for one of your site’s pages:
tC.getCookie('cookie_name')
You can use the following function to create custom data storage:
tC.setCookie('cookie_name', 'value', 'expiration')
To add data storage, you must go to the “Options” tab > “Data layer” > “Data Storage” and click “ADD DATA STORAGE”:
The “add” window consists of the following fields:
Name: Name of the Data Storage Container(s) to link:A menu that unfolds and shows all available containers Lifetime: A menu to select the cookie’s lifetime Type: the type of cookie/what it is used for Value: the values the cookie will take (a and b for ab testing, many more for n testing …)
Generates a unique ID for each visitor.
Example: Commanders Act can become your visitors’ unique reference ID to replace or enrich the ID generated by your partner solutions.
The “Do you want lifetime to be refreshed at each page view?” option changes the data storage’s lifetime based on the frequency of visits to the site. This option refreshes the data storage lifetime with each page view.
Example: you have set the data storage lifetime to 30 days and checked this option. If a user visits the page at 12 p.m. on 05/01/2015, the cookie will remain on the visitor’s computer until 12 p.m. on 05/31/2015, i.e. 30 days later. The cookie’s lifetime will refresh with each page view.
Saves the value of a URL parameter.
Example: if you want to save the value of the “utm_source” parameter, i.e. “google” in the URL https://www.site.com/landing?utm_source=google&utm_medium=cpc, you must enter the name of the parameter to save, which in this case would be “utm_source”
Assigns a score based on the number of page views.
Example: if you want to assign the score of “A” to visitors visiting 1 to 3 pages, a “B” to visitors visiting 4 to 7 pages and a “C” to visitors visiting 8 to 11 pages, you must enter the different ranges of page views and indicate each range’s score. The data storage value will be the score (A, B or C).
Saves the number of page views for a given visitor.
Example: you can use this data storage type if you want to save and send the user’s number of page views to one of your solutions or define a tag’s activation on the number of page views. Just select the “page views counter” data storage type, and the cookie’s value will increase automatically with each page view (1 page view: cookie value = “1”, 2 page views: cookie value = “2”, etc.)
Creating two visitor populations split 50/50.
Example: if you want to activate solution A for 50% of your visitors and solution B for the remaining 50%, all you need to do is indicate the data storage values for population A, “vendor_A” for example, and population B, “vendor_B”.
You will then be able to create a rule during the deployment process in the “Rules” section that activates solution A’s tags when the data storage value is “vendor_A”, and solution B’s tags when the value is “vendor_B”.
Note: this method is used regularly for A/B tests of two competing retargeting solutions.
Creating N visitor populations of equal size.
Example: if you want to launch an N test for 3 competing solutions, each solution will be assigned 33.3% of the traffic (100%/3); for 4 solutions, each solution will be assigned 25% of the traffic (100%/4), and so forth.
If you decide to activate solution A for 33.3% of your visitors, solution B for another 33.3% and solution C for the remaining 33.3%, you must enter the data storage value in each case. For example, “vendor_A” for solution A, “vendor_B” for solution B and “vendor_C” for solution C (1). Each value must be separated by a comma in order to be processed.
Saves a variable’s value.
Example: if at some point you want to save a Commanders Act data layer variable or any other JavaScript variable present on the page, you must enter the name of the variable to save.
For example, data storage allows you to save visitors’ user_id variables in order to recognize them if they return several days after leaving your site. To save the user_id variable value, you must enter “tc_vars[“user_id”]” or “tc_vars.user_id” (both formats are accepted) in the “Variable to save” field (1). If you want to save the value of an internal variable, you must enter the value using the following format: tC.internalvars.variable_name.