# Privacy

This page explains what nanolytics stores about your visitors, what the script keeps in their browser, how consent works, and where the data lives. The [privacy policy](/legal/privacy), [terms](/legal/terms) and [data processing agreement](/legal/dpa) are the binding documents; this page is a plain explanation of them.

## Controller and processor

You're the controller of the analytics data you collect, and nanolytics is your processor. The [data processing agreement](/legal/dpa) covers every plan, including Free, and you accept it when you sign up.

## What we store

For each event, nanolytics keeps:

| Field | What's kept |
|---|---|
| Page | The host and path. From the query string, only campaign parameters (`utm_*`, `ref`, `source`). The fragment is dropped |
| Referrer | The previous page's host and path, without its query string |
| Window width | One of 7 bands, from `xs` (under 576 px) to `3xl` (1920 px and over) |
| User agent | Stored as the browser sent it, and read as browser, OS and device |
| Location | Country, region and city, which Cloudflare derives from the IP address |
| Visitor | A hash of the visitor's identifier (see below), never the identifier itself |
| Time | When the event happened |

**Only if you send it:** a user ID (`nl.identify`), and the names and properties of your custom events. Use an internal ID rather than an email address, and keep personal data out of event names and properties.

**Only if you turn it on:** errors with their message and stack, page speed along with the element that was measured, outbound links and 404s, and session recordings. See [Tracking options](/docs/collect).

## What we never store

- **IP addresses.** nanolytics uses the IP address when an event arrives, to look up the location and, if there's no stored visitor ID, to compute the daily hash. It isn't saved with the event. Our hosting providers' request logs may keep it for a short time.
- **The rest of the query string.** Query strings often contain email addresses, password reset tokens and session IDs, so every parameter not listed above is dropped without being read. For ad-click IDs (`gclid`, `gbraid`, `wbraid`, `msclkid`), nanolytics only checks whether one is present.
- **Cookies.** The script doesn't set any.

## Browser storage

The script keeps a few entries in `localStorage` on your site's origin:

| Key | What it holds |
|---|---|
| `nl_v` | The visitor ID: 16 random bytes, created on the first visit |
| `nl_u` | The user ID passed to `nl.identify`, if any |
| `nl_c` | `0` when consent has been withdrawn |
| `nl_q` | Events waiting for the server to confirm them, for at most 72 hours |
| `nl_r` | Whether this session is being recorded, when replay is on |

With replay on, a tab that's being recorded also keeps the part of the recording it hasn't sent yet in `sessionStorage`.

The visitor ID isn't a cookie, but the EU's ePrivacy rules treat storing an identifier in the browser the same way, whichever mechanism is used. If your site needs consent for it, ask in your consent banner and start the script with consent withdrawn until the visitor agrees.

## Consent

Calling `nl.consent(false)` withdraws consent for that browser:

- The visitor ID and user ID are deleted from storage, and `nl.identify` doesn't store anything from then on.
- The choice is remembered (`nl_c`) on later pages.
- The visitor is counted with the daily hash instead, so they appear as a new visitor each day (see [Metrics](/docs/metrics)).
- Any recording in progress stops immediately, and anything it hadn't sent yet is discarded.

Calling `nl.consent(true)` restores consent, and the next event creates a new visitor ID.

To start with consent withdrawn, queue the call in the `<head>`, before the script tag:

```html
<script>window.nl=window.nl||{};(nl.q=nl.q||[]).push(['consent',[false]])</script>
<script defer src="https://app.nanolytics.dev/s/pk_….js"></script>
```

Then call `nl.consent(true)` when the visitor accepts. While consent is withdrawn, the browser holds no identifier. It only keeps the consent flag, events waiting to be confirmed and, with replay on, whether the session was picked for recording. This site, nanolytics.dev, runs its own script this way.

### The daily hash

The daily hash is a hash of a salt, your site, the IP address and the user agent.

- Each salt is used for one UTC day only, and it's deleted after 2 days.
- Once a salt is gone, its hashes can't be linked back to an IP address or to each other.
- Your site is part of the hash, so the same person gets a different ID on every site.

## Session replay

Replay is off until you turn it on. Once it's on, it records a share of sessions, 10% by default, and each session is recorded in full or not at all.

- **Masked in the browser by default:** the value of every input, whether typed or set by code, and `value` attributes. Text and media are shown.
- **Mask all text,** a site option, also masks every piece of text and replaces images, video, canvas, SVG and iframes with empty boxes of the same size.
- **Never recorded,** whatever your settings: password and hidden inputs, and inputs autocompleted as card numbers, security codes, expiry dates or one-time codes.
- **In your markup:** `data-nl-mask` and `data-nl-block` mask or block part of a page. With Mask all text on, `data-nl-unmask` shows part of a page.
- **Never captured:** canvas contents, iframes, console output and network requests. Recorded URLs keep only the origin and path.
- **Sessions not recorded:** browsers that send Global Privacy Control, browsers driven by automation, and browsers where consent has been withdrawn.

Masking happens before anything leaves the browser. Each stored chunk of a recording is encrypted with its own key, which is kept only in the database row that refers to it. See [Session replay](/docs/replay).

## Where data is stored

| What | Where |
|---|---|
| Events and recordings | Cloudflare R2, EU jurisdiction |
| Ingest and queries | Railway, Netherlands (europe-west4) |
| Accounts, sites and hashed API keys | PostgreSQL on PlanetScale, Netherlands (europe-west4) |
| Sign-in | WorkOS, United States, under the EU Standard Contractual Clauses |

Incoming requests pass through the Cloudflare data center nearest the visitor. The full list is on the [subprocessors](/legal/subprocessors) page.

Secret API keys are stored only as a SHA-256 hash and a prefix.

## Retention

- **Events and recordings** are kept at full detail for as long as your organization exists, on every plan.
- **Queries** are logged for 30 days. The log holds what was asked, not the answers.
- **One person's data:** to erase a visitor's or user's data, email [privacy@nanolytics.dev](mailto:privacy@nanolytics.dev) with their visitor ID or user ID.
- **Your organization's data:** when you close your organization, email the same address and we'll delete its data. Export anything you want to keep first, through the [Query API](/docs/api).
- **Inactive organizations:** an organization with no events and no sign-ins for 24 months may be deleted, after 30 days' notice.
