# Data storage

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**.

## Data storage usage

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')`

## Adding data storage

To add **data storage**, you must go to the “**Options**” tab > “**Data layer**” > “**Data Storage**” and click “**ADD DATA STORAGE**”:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-85d5283253fcc4e0cc691de0fa98908d918dbefa%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The “**add**” window consists of the following fields:

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-4d48fb34754ce8011bd5ddede55821d0820be009%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

**Name**: Name of the Data Storage\
**Container(s) to link:**&#x41; 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 …)

## Types of data storage

### **Unique ID**

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.*

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-32b6f4f5e12f4bd00bab3f91ef1235f6249503e4%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

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.*

### **URL parameter saver**

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”*[<br>](https://community.commandersact.com/wp-content/uploads/sites/2/2016/01/DS_URL_PAR_SAV.png)

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-b700e6c5fc144c8e89fa2ee8c47827423c7a9bfe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Scoring on page views**

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).*[<br>](https://community.commandersact.com/wp-content/uploads/sites/2/2016/01/DS_SCORING_PV.png)

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-27556ec81afb605dc79ff2c35e0351c0b30025cc%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Page views counter**

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.)*[<br>](https://community.commandersact.com/wp-content/uploads/sites/2/2016/01/DS_PV_COUNTER.png)

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-a492b568194455a70385ba64cdc29765d058984c%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### **A/B testing**

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”.*

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-075a9ef6012163f9b88e12dabd5a59b1b7e73be0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

*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.*

### **N testing**

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.*

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-9ae65d2d1a032f56a66c0216b3b6914e751a23b1%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Variable Saver**

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.*

<figure><img src="https://1259070148-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk6XpTQ2LaRLcr2tA-d%2Fuploads%2Fgit-blob-a356952029aae1fd99c604abf69e0b1194a38134%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
