# Cookies and browser storage

AB Tasty is relying on several first-party cookies and browser storage to run. Only one cookie is used as a tracking cookies, the other ones are technical cookies used for various technical purposes and never last for more than a session.

### Reference table

#### Cookies

| name                                    | purpose                                                                                                            | TTL                      |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------ |
| [ABTasty](#abtasty)                     | contains all the experiments data: visitor ID, campaignHistory, timestamp and account settings                     | 13 months                |
| [ABTastySession](#abtastysession)       | contains landing page URL. Also used to determine if new session                                                   | 30 minutes of inactivity |
| [ABTastyDomainTest](#abtastydomaintest) | Checks that we are operating on the expected domain                                                                | A few milliseconds       |
| [abTastyDebug](#abtastydebug)           | Set at `true` to enter debug mode. [See documentation](https://docs.abtasty.com/client-side/tag/tag-debug-module). | Manual deposit - session |

#### Browser storage

| name                                                | location        | purpose                                                                                         | TTL       |
| --------------------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------- | --------- |
| [ABTastyData](#abtastydata)                         | local storage   | contains all the viewed pages, events, transactions and segments for this visitor               | none      |
| [ABTastyUA](#abtastyua)                             | session storage | contains the user agent of the current visitor                                                  | session   |
| [ABTastyGeoloc](#abtastygeoloc)                     | session storage | contains the geolocation (city level), geolocated weather and IP address of the current visitor | session   |
| [ABTastyWidgets](#abtastywidgets)                   | local storage   | contains global recurrence information about displayed widgets                                  | none      |
| [ABTastyWidgets](#abtastywidgets-session)           | session storage | contains session recurrence information about displayed widgets                                 | session   |
| [ABTastyWidgetsTemporary](#abtastywidgetstemporary) | session storage | help the tag following the widgets recurrence over several tabs                                 | temporary |
| [ABTastyEngagementLevel](#abtastyengagementlevel)   | session storage | contains the engagement level cluster                                                           | session   |
| [ABTIsDatalayerChecked](#abtisdatalayerchecked)     | session storage | help the tag & connector read the website datalayer with the right method                       | session   |

### Cookies

#### ABTasty

```js
uid=zed18spa36wefrnq    // Unique visitor ID
&fst=1632216663697      // First session timestamp
&pst=-1                 // Previous session timestamp
&cst=1632216663697      // Current session timestamp
&ns=1                   // Amount of sessions for this visitor
&pvt=1                  // Total amount of viewed pages
&pvis=1                 // Same but during the current session
&th= 661111.820024.1.1.1.1.1632216664066.1632216664066.1.2
    _661112.820025.1.1.1.1.1632216664068.1632216664068.1.2
    _678020.840750.1.1.1.1.1632216664069.1632216664069.1.2
    _686114.850911.1.1.1.1.1632216664460.1632216664460.1.2
    _698373.866381.1.1.1.1.1632216664070.1632216664070.1.2
    _699307.0.1.1.1.1.1632216664071.1632216664071.1.2
    _718867.893154.1.1.1.1.1632216664072.1632216664072.1.2
    _722154.897293.1.1.1.1.1632216664448.1632216664448.1.2
    _753792.936854.1.1.1.1.1632216664422.1632216664422.1.2
    // campaignID
    // .variationID
    // .number of pages where the campaign has been seen
    // .same but during the current session
    // .number of sessions where the campaign has been seen
    // .variation is applied (0/1)?
    // .first timestamp the visitor has seen the campaign
    // .last timestamp the visitor has seen the campaign
    // .variant served by a random allocation (0: false/1: true)
    // .number of last seen session according to session list
```

#### ABTastySession

```js
mrasn=686556.853746                             // Generated hash for redirection test 
                                                // (can be deactivated from the settings)
&lp=http%253A%252F%252Fvanilla-project.fr%252F  // Landing page for current session
```

#### Technical cookies

**ABTastyDomainTest**

This cookie is set by the tag to check if he's correctly operating on the domain it is supposed to. This cookie shouldn't last for more than a few milliseconds.

**abTastyDebug**

This cookie needs to be manually created in order to activate the [debug mode](https://docs.abtasty.com/client-side/tag/tag-debug-module).

#### Use of local storage instead of cookies for tracking

In your [AB Tasty account settings](https://app2.abtasty.com/settings/cookies/deposit), you can set our tag to use local storage instead of a first-party cookie. The [ABTasty](#abtasty) cookie will no longer exist and be replaced by the equivalent in the local storage.

:::caution The main difference between cookies and local storage is their scope. Our cookie applies for the current domain and all the subdomains (unless restrictions have been setup in your AB Tasty account settings) whereas local storage is unique for each subdomains. :::

#### Cookie limit

Our cookie has a fixed limit of **3900 bytes**. Over this threshold, the tag will block its initialization to avoid going over the global browser limitation.

### Browser Storage

#### `ABTastyData`

This object contains all visited pages, segments, transactions and events (Action Tracking) for the current visitor. See [related hits documentation here](https://docs.abtasty.com/client-side/data-apis/universal-collect/uc-hits).

```json
{
   "VisitedPages":[
      {
         "url":"http://vanilla-project.fr/",
         "visite":1,
         "time":1632216663697,
         "title":"Test A/B Responsive"
      },
      {
         "url":"http://vanilla-project.fr/",
         "visite":2,
         "time":1632220364572,
         "title":"Test A/B Responsive"
      }
   ],
   "segments":[
      {
         "sampleSegmentKey":"sampleSegmentValue",
         "sampleSegmentKey2":"sampleSegmentValue2",
         "qt":1632220364752
      }
   ],
   "transactions":[
      {
         "id":"1234ABCD",
         "value":1234,
         "affiliation":"Purchase",
         "time":1632216664147
      },
      {
         "id":"5678EFGH",
         "value":1234,
         "affiliation":"Purchase",
         "time":1632216664149
      }
   ],
   "ActionTracking":[
      {
         "name":"Popin image displayed",
         "value":0,
         "time":1632216664761
      },
      {
         "name":"Popin simple closed",
         "value":0,
         "time":1632216664765
      }
   ]
}
```

#### `ABTastyUA`

This object contains the user agent that has been detected for the current visitor.

```json
{
   "type":"Desktop",
   "os":{
      "name":"Windows 10",
      "version":"NT 10.0"
   },
   "browser":{
      "name":"Chrome",
      "version":"93.0.4577.82"
   }
}
```

**Type description: `UAResponse`**

| Key                 | Type    | Description                                                                                                                              |
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **browser.name**    | string  | The name or type of the browser on the device.                                                                                           |
| **browser.version** | string  | The browser version on the device.                                                                                                       |
| **is\_bot**         | boolean | *(Optional)* Identifies non-human traffic (robots, crawlers, checkers, download agents, spam harvesters and feed readers).               |
| **os.name**         | string  | The name of the Operating System installed on the device.                                                                                |
| **os.version**      | string  | The Operating System initial version installed on the device.                                                                            |
| **type**            | string  | Primary hardware type. Please see the [complete list](https://deviceatlas.com/device-data/explorer/#defined_property_values/19/4751724). |

#### `ABTastyGeoloc`

This object contains the geolocation, weather and the IP address that has been detected for the current visitor. The IP address is used for IP exclusion and campaign QA only.

```json
{
   "ip_address":"185.13.36.70",
   "country_name":"France",
   "country_iso_code":"FR",
   "state":"Pays de la Loire",
   "state_iso_code":"PDL",
   "city":"Nantes",
   "city_id":2990969,
   "city_confidence":-1,
   "postal_code":"44100",
   "latitude":47.2145,
   "longitude":-1.5512,
   "accuracy_radius":1,
   "time_zone":"Europe/Paris",
   "least_specific_subdivision":{
      "name":"Pays de la Loire",
      "iso_code":"PDL"
   },
   "most_specific_subdivision":{
      "name":"Loire-Atlantique",
      "iso_code":"44"
   },
   "weather":{
      "temperature":16.04,
      "main":"Clouds",
      "description":"scattered clouds"
   }
}
```

#### `ABTastyAbandonedCart`

This object contains the last abandoned cart data that has been detected for the current visitor. This entry is used by the Abandoned Cart targeting criteria.

```json
{
   "customerId": "q4wt261uw8q38",
   "sessionStart": 1637319225,
   "cartId": "CARTPROD0001",
   "totalProducts": 11,
   "totalPrice": 520
}
```

#### `ABTIsDatalayerChecked`

This object only contains technical information for the tag, which refers to the structure of a website's data layer.

```json
{ 
"ABT_IS_DATALAYER_CHECKED: "true"
}
```

#### `ABTastyWidgets`

This object contains data about the displayed widgets. It is stored in local storage if their recurrence goes beyond the session.

```json
{
   "popin-simple_10a49c2d_756225":{
      "type":"closing",
      "stamp":1633440617095
   }
}
```

#### `ABTastyWidgets (session)`

This object contains data about the displayed widgets. It is stored in session storage if their recurrence sticks to the session.

```json
{
   "popin-simple_10a49c2d_756225":{
      "type":"display",
      "stamp":1632231402736
   }
}
```

#### `ABTastyWidgetsTemporary`

This object contains a copy of the existing storage in order to replicate recurrence from one tab to another. It is immediately removed when becoming unnecessary.

```json
{
   "popin-simple_10a49c2d_756225":{
      "type":"closing",
      "stamp":1633440617095
   }
}
```

#### `ABTastyEngagementLevel`

This object contains the engagement level cluster that is used for the corresponding segment criterion.

```json
{
   "cluster_loyalty":{
      "loyal"
   }
}
```
