PureStats documentation

Consent mode

Configure PureStats to wait for analytics consent before tracking.

Consent mode lets sites control when PureStats sends analytics events.

Default behavior

Without consent mode, the tracker sends pageviews when it loads, subject to site settings such as path exclusions, domain validation and bot filtering. It reads these settings on every page load and waits up to 1.5 seconds for them before the first pageview; the browser usually answers this request from its cache.

What the tracker stores in the browser

In its default mode the tracker stores nothing in the visitor's browser: no cookies, no localStorage and no sessionStorage. Tracker versions before 1.9.0 cached the site settings in localStorage; 1.9.0 removes that entry.

Some optional features store data, and only when you use them:

Feature What is stored
Cross-domain stitching The first-party cookie psid with a random visitor and session ID, and a copy in localStorage
Experiments The assigned variant in localStorage and the exposure of the current session in sessionStorage
Consent API The visitor's consent decision in localStorage, when your site calls consent.grant(), deny() or revoke()
Tracking test mode The test token in sessionStorage, during a test session you start

Consent-gated behavior

When consent mode is Manual opt-in required, the tracker waits until your consent banner or CMP grants analytics permission.

Example:

window.purestats?.consent.grant();

If consent is denied, call window.purestats?.consent.deny(). The consent mode itself is set in Site settings → Privacy settings; you do not need to add data-consent-mode to the tracker snippet.

Integrating with a CMP

Connect your consent management platform to PureStats by calling the consent method when the visitor chooses analytics consent. Store consent according to your legal and product requirements.

Revoking consent

If a visitor revokes consent during a session, call:

window.purestats?.consent.revoke();

After this, your application should stop sending analytics events.

Verification

When consent mode is Manual opt-in required, the tracking setup may show Snippet installed and Script loads before First hit received. That is expected until consent is granted.