Skip to Content

Consent and Cookieless

Run analytics with or without stored identifiers

This is not legal advice. Consult a lawyer for your specific use case.

FastStats supports normal analytics, anonymous cookieless analytics, and fully disabled collection. Choose an initial mode with consent and change it at runtime with setConsentMode.

How Identifiers Work

With granted consent, the SDK keeps an anonymous identifier in localStorage and session state in browser storage. This allows it to recognize returning visitors and measure sessions.

Anonymous mode stores nothing in the browser. The session lives in memory, so a reload starts a new session. To still count unique visitors, FastStats derives a visitor ID on its servers, as described below.

How Cookieless Visitors Are Counted

For each cookieless request, FastStats computes a visitor ID from the IP address, the user agent, your site, and a secret salt that changes every day (UTC).

  • A visitor keeps the same ID for the rest of the day on one site, across reloads and sessions.
  • On the next day, or on another site, the same visitor gets an unrelated ID. Cookieless visitors are never recognized as returning on a later day.
  • Each salt is deleted when its day ends. Without it, that day’s IDs can no longer be traced back to an IP address.
DataStored
IP addressNo. Used for the visitor ID, country and IP rules only
User agentNo. Only browser, OS, their versions and device type
Daily visitor IDYes
Session IDYes. Created in the browser and kept in memory
External ID, traitsNo. Identification is disabled

Cookieless mode still processes each visitor’s IP address and user agent to compute the daily ID. Describe this in your privacy notice.

ModeBehavior
"granted"Tracks normally and stores an anonymous identifier
"anonymous"Tracks with a daily ID and stores nothing
"denied"Sends no analytics and stops optional extensions

The default is "granted". If consent has not yet been decided, start with "anonymous" for cookieless counts or "denied" to send nothing.

<Analytics siteKey="your_site_key" consent="denied" />

Set cookieless: true when a site should always avoid stored identifiers. This forces cookieless collection even while consent is "granted".

import { useConsentMode } from "@faststats/react";

const setConsentMode = useConsentMode();

<button onClick={() => setConsentMode("granted")}>Accept</button>
<button onClick={() => setConsentMode("denied")}>Decline</button>

React also exports useOptIn and useOptOut as shortcuts for setting "granted" and "denied".

Switching to "denied" stops collection and discards data buffered by active extensions. Switching back starts tracking again. Moving between "anonymous" and "granted" rotates the page and identity context so the two modes do not share an anonymous identifier.

The React component applies changes to its consent prop to the active client, which works well when your consent manager already exposes React state.

<Analytics siteKey="your_site_key" consent={consentMode} />