> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usertick.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cookies and consent

> Every cookie and storage key the Usertick widget and hosted survey pages keep in a visitor's browser, and how to load the widget only after a visitor consents.

The Usertick widget keeps a few values in your visitors' browsers: what each survey did for the visitor, a random visitor ID, visit counters and the `identify()` record. Everything it stores is first-party, on your site's own domain, and the widget sets no third-party cookies. This page lists every key, so you can describe them in your cookie notice and in your consent tool.

> [!NOTE]
>
> You decide whether your site needs your visitors' consent before the widget runs, and you ask for it. Usertick shows no consent banner, and the widget doesn't read the browser's Do Not Track or Global Privacy Control signals. When your site needs consent, load the Usertick tag only after the visitor gives it, as described in [Load Usertick after consent](#load-usertick-after-consent).

## What the widget stores on your site

The widget keeps the values in the table below in first-party cookies on your domain (path `/`, `SameSite=Lax`, not `HttpOnly`). When the browser blocks cookies, it keeps the same values in `localStorage` instead, under the same names. A cookie lasts 365 days from the last time the widget wrote it.

| Name | Purpose | Lifetime |
| - | - | - |
| `usertick_vid` | A random visitor ID created in this browser. It keeps the visitor on the same side of a survey's traffic share and in the same variant, and a response carries it as the anonymous ID | 365 days; replaced by `logout()` after a signed-in user |
| `usertick_visits` | The number of visits, for the visitor type rule (new or returning) | 365 days from the last page view |
| `usertick_seen_at` | The time of the last page view, so a page view after 30 idle minutes counts as a new visit | 365 days from the last page view |
| `usertick_display_<survey ID>` | How many times the survey showed and the times of the last three showings, for its repeat rule and for earlier survey rules | 365 days from the last showing |
| `usertick_submitted_<survey ID>` | When the visitor answered the survey, so an answered survey doesn't come back | 365 days |
| `usertick_dismissed_<survey ID>` | When and how many times the visitor closed the survey without answering, for the wait after a close | 365 days from the last close |
| `usertick_event_count_<survey ID>` | How many matching custom events the visitor fired, for a trigger that waits for several | 365 days from the last count |
| `usertick_test` | A check that the browser accepts cookies. The widget deletes it right after writing it | Removed at once |

The widget also uses `localStorage` and `sessionStorage` on your domain:

| Name | Storage | Purpose | Lifetime |
| - | - | - | - |
| `usertick_user` | `localStorage` (a cookie without the hash when `localStorage` is blocked) | The user ID, traits and hash your page passed to `Usertick.identify()` | Until `logout()`, `identify(null)` or `reset()` |
| `usertick_submission_queue` | `localStorage` | Responses that couldn't be sent yet, with their answers and respondent details, sent again in the background | Up to 7 days per response |
| `usertick_submission_lease_<response ID>` | `localStorage` | A short lock, so two open tabs never send the same waiting response at once | About 25 seconds |
| `usertick_config_<site ID>` | `localStorage` | The npm package only: a copy of the site's survey settings, used when they load slowly | At most 24 hours |
| `__usertick_session_start`, `__usertick_focused_ms` | `sessionStorage` | When this browser session started and how long the site was in front of the visitor, for the time on site and engaged visitor triggers | Until the tab closes |
| `__usertick_pages` | `sessionStorage` | Pages viewed this session, for the pages viewed trigger | Until the tab closes |
| `__usertick_visit` | `sessionStorage` | The paths viewed and site searches made this visit, for the hesitation, can't find it and engaged visitor triggers. They stay in the browser and are never sent | Until the tab closes |
| `__usertick_interactions` | `sessionStorage` | Clicks, copies and form changes counted for the engaged visitor trigger | Until the tab closes |
| `__usertick_landing` | `sessionStorage` | The referrer and query string of the first page of the session, for the referrer and campaign parameter rules. They stay in the browser and are never sent | Until the tab closes |
| `__usertick_dismissed_<survey ID>` | `sessionStorage` | The visitor closed the survey during this visit | Until the tab closes |
| `usertick_country` | `sessionStorage` | The visitor's country, looked up only when a survey has a country rule or a country variant | Until the tab closes |

The widget doesn't fingerprint the browser, and it sends no page views or survey showings to Usertick: a response is sent when the visitor submits it. See [Identify your users](https://docs.usertick.com/installation/identify.md) for what a response carries.

## What hosted survey pages store

A survey's own page, at its link, QR code or email link, keeps these values in `sessionStorage`, which the browser deletes when the tab closes:

| Name | Purpose | Lifetime |
| - | - | - |
| `usertick_link_vid` | A random ID for this tab, so a reload shows the same variant. A response carries it as the anonymous ID | Until the tab closes |
| `__usertick_link_user_<link ID>` | The user ID and hash the link carried, so they can leave the address bar and a reload still sends them | Until the tab closes |
| `usertick_country` | The visitor's country, looked up only when the survey has a country rule or a country variant | Until the tab closes |

Survey pages load the theme's fonts from Usertick (`cdn.usertick.com`), never from Google Fonts.

## Load Usertick after consent

When your site needs consent before the widget runs, don't put the Usertick tag in the page as is. Load it once the visitor has consented, on every page load. The widget writes nothing before its code loads.

> [tab] Consent tool category
>
> Most consent tools can hold a script until the visitor accepts a category. Give the Usertick tag the category that covers it on your site, such as functional or analytics, in the way your consent tool's documentation describes. The tool then adds the tag once the visitor accepts that category, and on later pages when their earlier choice allows it.

> [tab] Consent callback
>
> Add the tag from your consent tool's callback. Replace `<site ID>` with the ID from your install code in **Settings → Sites**.
>
> ```js theme={null}
> function loadUsertick() {
>   if (document.querySelector('script[src="https://cdn.usertick.com/s/<site ID>.js"]')) return;
>   const script = document.createElement("script");
>   script.async = true;
>   script.src = "https://cdn.usertick.com/s/<site ID>.js";
>   document.head.appendChild(script);
> }
>
> // Call loadUsertick() when the visitor accepts the category that covers Usertick,
> // and on every later page load when their saved choice allows it.
> ```

> [tab] npm package
>
> Call `Usertick.init()` only after the visitor consents, and `Usertick.identify()` only after that too, because `identify()` stores the user ID and traits as soon as it runs. Importing the package stores nothing beyond the `usertick_test` check, which it deletes at once.
>
> ```js theme={null}
> import Usertick from "@usertick/snippet";
>
> // In your consent tool's callback, once the visitor accepts:
> Usertick.init({ site_id: "<site ID>" });
> ```

### When a visitor withdraws consent

When a visitor withdraws consent on a page where the widget runs, clear what it stored and remove it from the page, then stop loading the tag on later pages:

```js theme={null}
if (window.Usertick) {
  Usertick.reset();
  Usertick.destroy();
}
```

`reset()` deletes the widget's cookies and its `localStorage` and `sessionStorage` keys in this browser, except responses that are still waiting to be sent, which stay until they are sent or 7 days pass, and the looked-up country, which goes when the tab closes. `destroy()` removes the widget's surveys, listeners and timers from the page.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.