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

# Cookies and consent

> OpenRevenue stores nothing on your visitors' devices by default. Learn what that means for your cookie banner, and how to keep returning visitors with consent.

## Default: nothing stored on the device

By default, the tracker sets no cookies and writes nothing to `localStorage` or `sessionStorage`. To recognize a visitor, OpenRevenue makes a daily ID on its servers from:

* a random salt that is kept secret, changed every day and then deleted,
* your project ID,
* the visitor's IP address, shortened to its network (the last part is removed),
* the browser's user agent.

Because the salt is deleted, nobody, including OpenRevenue, can recreate an old ID or link it to a person. Because your project ID is part of the hash, the same person gets different IDs on different websites. Raw IP addresses are not stored with the event.

Under the EU and UK rules on cookies (ePrivacy), consent is needed to store or read information on a visitor's device. The default tracker does neither, so in most setups you do not need a cookie banner for OpenRevenue. You still need to mention OpenRevenue in your privacy policy, and other tools on your site may need consent of their own.

> [!NOTE]
>
> This is not legal advice. If your site has specific legal requirements, check with your own advisor.

### What the daily ID means for your reports

| Report | Default (storage-free) | With a stored visitor ID |
| - | - | - |
| Visitors, pageviews, sources, pages, countries | Accurate | Accurate |
| Sessions and bounce rate | Accurate (joined on the server, 30-minute idle timeout) | Accurate |
| Unique visitors across several days | A person who visits on 3 different days counts 3 times | Counted once |
| New vs returning visitors, visitor profiles | Limited to one day | Full history |
| Revenue attribution | When the purchase happens on the same day as the visit | Across visits on different days |

Old IDs set by earlier versions of the tracker (`_ova_vid`, `_ova_uid`, `_ova_sid`) are deleted automatically in the default mode.

## Keep a visitor ID with consent

If you show a cookie banner anyway, you can keep returning visitors for people who accept. Add `data-persist="consent"` to the script:

```html index.html theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
<script
  src="https://api.openrevenue.com/tracker.js"
  data-site="your-project-id"
  data-persist="consent"
  defer
></script>
```

The tracker starts without storing anything. When your banner reports the visitor's choice, call `consent`:

```js banner.js theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
// The visitor accepted analytics cookies:
window.openrevenue.consent(true)

// The visitor declined, or withdrew consent later:
window.openrevenue.consent(false)
```

After `consent(true)`, the tracker keeps today's ID in a first-party cookie and in `localStorage` (`_ova_vid`), so the visit continues without a break. `consent(false)` deletes the stored ID and goes back to storage-free tracking. Call `consent(true)` on every page load where your banner has a stored "accepted" answer.

With the npm package, pass `persist: "consent"` to `init` and import `consent`:

```ts app.ts theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
import { consent, init } from "openrevenue"

init({ siteId: "your-project-id", persist: "consent" })
consent(true) // safe to call before init finishes
```

## Always keep a visitor ID

`data-persist="true"` (or `persist: true`) stores the visitor ID on every visit, as earlier versions of the tracker did. The ID lasts up to two years. In the EU and UK this usually needs consent, so load the script only after the visitor agrees, or use `data-persist="consent"` instead.

## What the tracker can store

| Name | Where | Default | `data-persist="consent"` | `data-persist="true"` |
| - | - | - | - | - |
| `_ova_vid` | Cookie and `localStorage` | Never | After `consent(true)` | Always |
| `_ova_sid` | `sessionStorage` | Never | After `consent(true)` | Always |
| `_ova_uid` | `localStorage` | Never, the [identify](https://docs.openrevenue.com/advanced/custom-events.md#identify) hash stays in memory | After `consent(true)` | When you call `identify` |

## Opt-out signals

The tracker sends nothing when the browser has Do Not Track or Global Privacy Control turned on. The collector also ignores requests with the `Sec-GPC: 1` header.


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