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

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# How CrispStats counts visitors without cookies

> CrispStats identifies visitors with a daily-rotating hash of a random salt, the site, the IP address and the User-Agent. No cookie, nothing stored in the browser.

CrispStats counts visitors without cookies by computing an anonymous id on the collector for every event: a hash of a random salt that changes every day, your site, the visitor's IP address and their User-Agent. The script sets no cookie and writes nothing to the visitor's device, and the IP address and User-Agent are discarded once the id is computed. The trade-off is that a visitor is recognised for one day only.

This page explains how the id is built, when the salt changes, why ids from different days cannot be linked, and what that means for returning-visitor numbers. If you need to recognise visitors across days, see [persistent visitors](https://docs.crispstats.com/privacy/persistent-visitors.md).

## What the browser stores

With the default script tag, nothing. The script:

* sets no cookie,
* writes nothing to `localStorage`, `sessionStorage` or IndexedDB,
* reads one `localStorage` key, `crispstats_ignore`, which only you set in your own browser to [exclude your visits](https://docs.crispstats.com/tracking/exclude-traffic.md).

The only exception is [persistent visitors](https://docs.crispstats.com/privacy/persistent-visitors.md), which you turn on explicitly with `data-persist` and a site setting.

## How the visitor id is computed

For each event from a browser, the collector computes:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
visitor id = first 32 hex characters of SHA-256(daily salt | site id | IP address | User-Agent)
```

| Input | Where it comes from |
| - | - |
| Daily salt | 32 random bytes generated by CrispStats for the current day in your site's timezone. It is never sent to the browser or shown in the dashboard. |
| Site id | The internal id of your site. The same browser gets a different id on each site, so ids cannot be matched across sites. |
| IP address | The address of the request, read in memory. When you [proxy the collector](https://docs.crispstats.com/tracking/proxy.md) through your own domain, the visitor address your proxy forwards in `X-Forwarded-For` is used instead: the first public address on `/p/` routes, the first entry when it is public on the older `/api/event`. |
| User-Agent | The browser's `User-Agent` header, cut at 512 characters. |

The result is a 32-character hex string. It is stored with each event in place of anything that identifies the device. The IP address and User-Agent are used for this hash, for [bot filtering](https://docs.crispstats.com/privacy/bot-filtering.md) and to read the browser, operating system and device type. They are then discarded: neither is stored or logged.

## Salt rotation and expiry

Each day in your site's timezone has its own salt. The day is the one your reports use, set in **Settings**, **General**, so it starts at local midnight (or, on the rare day a clock change skips midnight, at the first minute that exists):

* A scheduled job runs every 15 minutes and makes sure the salt for every timezone's day that starts in the next 26 hours exists, so a new salt is ready hours before your site's midnight.
* A salt expires 35 minutes after its day ends, when the key-value store deletes it. A collector instance that still holds a copy in memory drops it the next time it looks up a salt, and stops using it at that moment either way.
* Once the salt is gone, nobody, including CrispStats, can recompute that day's ids from an IP address and User-Agent.

> [!NOTE]
>
> If the salt store cannot be reached, each collector instance makes a random salt of its own, keeps it only in memory and tries the store again a minute later. Nothing is ever derived from a secret or the date, so no salt can be computed again. The cost is that the same person can count as more than one visitor while the store is unreachable.

## The 30-minute grace after midnight

A visit that is in progress when your site's day changes should not be cut in two. For the first 30 minutes of the new day, the collector computes both today's id and yesterday's id for each event. If the visitor has an open session under yesterday's id, meaning an event in the last 30 minutes, the event joins that session and keeps the old id. Otherwise the event uses today's id. From 30 minutes into the day only today's id is computed, so any later event starts a new session under today's id.

This is why yesterday's salt lives 35 minutes past midnight: 30 minutes for the session timeout plus 5 minutes of margin.

## Why ids from different days cannot be linked

Today's id and yesterday's id for the same browser are hashes with different random salts. Nothing in either id reveals the other, and once yesterday's salt expires there is no way to compute yesterday's id again. The stored events do not contain the IP address or User-Agent, so the link cannot be rebuilt from the data either.

The only exception is the grace window above: a session that crosses midnight keeps yesterday's id for at most 30 minutes.

## What this means for your numbers

| Situation | How it is counted |
| - | - |
| One browser, several visits on the same day | One visitor, with one session per visit. |
| One browser on Monday and on Tuesday | One visitor each day. A report for the whole week counts two visitors. |
| One person on a phone and a laptop | Two visitors, because the User-Agent and usually the IP address differ. |
| One browser that changes network during the day, such as Wi-Fi to mobile data | Two visitors, because the IP address changed. |
| Two people on the same network with identical browsers and versions | One visitor, because the inputs to the hash are the same. |
| A browser that updates during the day | Two visitors, because the User-Agent changed. |

Over a period longer than a day, the same browser counts once for each day it visited, in your site's timezone. See [counting visitors](https://docs.crispstats.com/concepts/metrics.md#counting-visitors).

Changing your site's timezone starts a new day for its visitors within a minute: everyone on the site gets a new id, so a visitor already counted that day counts once more, and an open visit continues as a new session.

Returning-visitor metrics are limited to what one day can show:

* **Retention cohorts** count a return on a later day only for visitors you [identify](https://docs.crispstats.com/track/identify-users.md) with `crispstats.identify()`, and for persistent visitors if you turn them on.
* **Revenue attribution** links a payment to the visit when you pass the visitor id at checkout. Because the id changes daily, read it with `crispstats.id()` at checkout time rather than storing it for later. See [visitor id at checkout](https://docs.crispstats.com/revenue/visitor-id-at-checkout.md).
* **Server-side events** join a visit only when you pass a visitor id from `crispstats.id()`. They carry no IP address or User-Agent of their own.

## Learn more on crispstats.com

* Glossary: [cookieless tracking](https://crispstats.com/glossary/cookieless-tracking), [visitor hash](https://crispstats.com/glossary/visitor-hash) and [unique visitor](https://crispstats.com/glossary/unique-visitor).
* Article: [cookieless analytics explained](https://crispstats.com/blog/cookieless-analytics-explained).

## Next steps

> [card] [Persistent visitors](https://docs.crispstats.com/privacy/persistent-visitors.md)
>
> Recognise the same visitor across days, and what that requires.

> [card] [Data collected](https://docs.crispstats.com/privacy/data-collected.md)
>
> The exact fields each event carries and how long they are kept.

> [card] [Compliance facts](https://docs.crispstats.com/privacy/compliance.md)
>
> A factual summary for a privacy or legal review.


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