Guide

Cookieless until consent, tool by tool

The setting in Pug, PostHog, Mixpanel, Amplitude, Matomo and Google Analytics 4 that stores nothing on the visitor’s device until they answer your banner, what each one sends and counts before then, what joins the visitor’s ID once they accept, and the catch in each. Checked on each vendor’s docs, December 3, 2026.

The six tools compared

Five settings store nothing and send nothing until the visitor answers: PostHog’s cookieless_mode: 'on_reject', Mixpanel’s consent_mode: 'require_consent', Amplitude with init() deferred, Matomo’s requireConsent, and Consent Mode’s basic setup in GA4. Four store nothing and keep counting: Pug’s default, Mixpanel’s consent_mode: 'exempt', Matomo’s requireCookieConsent, and Consent Mode’s advanced setup. The table gives one storage-free setting per tool; the sections below cover the alternatives, including the ones that still write to the device.

What each tool stores and sends before the visitor answers, and what happens on accept, from each vendor’s own docs and release notes, checked December 3, 2026.
ToolSettingStored before an answerSent before an answerAccept withEarlier activity after accept
PugtrackingConsent, 'cookieless' by defaultNothingEvents, with an ID the server derives each dayoptInTracking()Stays apart from the new ID
PostHogcookieless_mode: 'on_reject', plus the project’s Enable cookieless tracking settingNothingNothingopt_in_capturing()Nothing was sent
Mixpanelconsent_mode: 'require_consent', from mixpanel-browser 2.85.0NothingNothing; with 'exempt' (2.87.0), page views, clicks, scrolls and page exits that can’t identify the visitoropt_in_tracking()An identify() made before consent is applied; exempt events stay apart
Amplitudeinit() deferred until consentNothingNothing; track() calls wait in page memoryinit()Calls made on that page go out under the new device ID
MatomorequireCookieConsent, or requireConsent to send nothingNo cookies, and the tracker has no localStorage codeEvery request, matched to visits by a hash Matomo calls the config_idrememberCookieConsentGivenCan stay in the open visit through the config_id
GA4Consent Mode, analytics_storage denied by defaultNo analytics or ad cookiesAdvanced setup: pings with no visitor ID. Basic: nothinggtag('consent', 'update', ...)Stays apart: the pings carry no persistent ID

Why “no cookies” is not enough

Article 5(3) of the ePrivacy Directive, the rule behind consent banners, is about storing information on the visitor’s device or reading it back, and it never names cookies. The EDPB’s Guidelines 2/2023 list local storage and WebSQL beside cookies (paragraph 44), so an SDK that moves its ID from a cookie into localStorage has changed the API, not the position. That is why every setting below is judged on what it stores anywhere on the device, and why Mixpanel’s opt-out flag and Amplitude’s unsent-event queue count against the settings that leave them in place.

Memory-only state is the property to look for: an ID held in page memory is gone when the page closes, so nothing on the device ties one visit to the next. It does not take a tool outside Article 5(3) on its own. The same guidelines name RAM as a storage medium (paragraph 38), set no minimum time for information to count as stored (paragraph 37), and treat JavaScript that makes the browser send information as access (paragraph 33). Pug’s own docs say as much of its cookieless state, since the SDK still reads screen size, locale and client hints. What the law says about cookieless tracking and fingerprinting covers the access side and IP addresses. None of this page is legal advice.

We build Pug. Its Web SDK (@pug-sh/browser) starts in its 'cookieless' consent state, so a plain init() already stores nothing; the options below decide what a rejection means and keep the answer across reloads.

import { init, optInTracking } from '@pug-sh/browser'

init('your-project-id', {
  apiKey: 'pub_your_key',
  trackingConsent: { onReject: 'cookieless', persist: true },
})

// on accept
optInTracking()

Before consent. Events go out with no session, anonymous ID or user ID, and nothing is written to the device, not even the queue of unsent events (a storage probe is written and deleted during init()). The server gives each visitor an ID from a keyed hash of the project, IP address and User-Agent under a salt that is deleted within 48 hours; cookieless identity, built on a salt that deletes itself covers the construction. Those visitors count in event totals and in sessions, which the server stitches on a 30-minute inactivity window, and stay out of unique users, per-user averages, funnels, retention and user flows unless a query asks for them with include_cookieless. Autocapture keeps running: page views, clicks, scrolls, form starts and submits, rage clicks and dead clicks.

On accept. optInTracking() moves the visitor to 'granted': the SDK stores an anonymous ID and a session from the next event, and identify() can merge them into a profile. The events sent before that are never linked to the new ID, so a visitor’s first pages stay anonymous.

The catch. optOutTracking() applies your reject state, which is 'denied' (send nothing) unless you set onReject: 'cookieless' as above. identify() does nothing until consent is granted. And the cookieless state belongs to the Web SDK: Pug’s Android, iOS, React Native and Flutter SDKs have only granted, their default, and denied. Click, scroll and form autocapture is web-only as well. The three states and the banner wiring are in how to implement cookieless tracking and the Web SDK’s consent reference.

PostHog: cookieless_mode: 'on_reject'

PostHog’s web SDK keeps its state in localStorage and a first-party cookie by default. Its cookieless_mode option takes 'always', which never stores anything and ignores the visitor’s answer, or 'on_reject', the one for a site with a banner (PostHog’s data collection docs).

posthog.init('<ph_project_token>', {
  api_host: 'https://us.i.posthog.com',
  cookieless_mode: 'on_reject',
})

// on accept
posthog.opt_in_capturing()
// on reject: count with a hash derived on PostHog's servers
posthog.opt_out_capturing()

Before consent. With 'on_reject', PostHog stores nothing and sends nothing until the visitor answers. A visitor who declines is counted with an ID PostHog’s servers derive from a hash of the project, a daily salt, the IP address, the User-Agent and the hostname, and the salt is deleted once that day’s events are processed. PostHog warns that those visitors “appear as different people each day”, so weekly and monthly unique users run high, and that two visitors on one IP address with the same browser version and operating system can hash to one person (PostHog’s cookieless tracking tutorial). Session replay and surveys stay off for them.

PostHog’s consent guide recommends a different pattern first: opt_out_capturing_by_default: true, then opt_in_capturing() on accept. That sends no events before consent, but it is not storage-free on its own. The SDK turns off its cookie and localStorage persistence for an opted-out visitor only when opt_out_persistence_by_default is true or cookieless_mode is 'on_reject' (posthog-js core source), and feature flags still load while the visitor is opted out, with requests that carry the distinct ID.

To count visitors before they answer, persistence: 'memory' keeps PostHog’s state, anonymous ID included, for the duration of one page view, and PostHog’s docs switch it to 'localStorage+cookie' with set_config() on accept (PostHog’s persistence docs). Each full page load before that mints a new anonymous ID, so it counts as a new visitor.

On accept. opt_in_capturing() makes PostHog store a cookie and a persistent distinct ID. Under 'on_reject' nothing was sent before the answer, so there is nothing earlier to join.

The catch. The init option does nothing on its own: until Enable cookieless tracking is on under Settings > Project > Web analytics, PostHog discards cookieless events and shows an ingestion warning. Two other options change what a visitor who hasn’t answered gets: with opt_out_capturing_by_default: true, or with respect_dnt: true in a browser sending Do Not Track, PostHog treats them as declined and sends cookieless events at once. And cookieless events lose their IP address before PostHog’s transformations run, so they get no GeoIP or bot detection.

Mixpanel’s JavaScript SDK keeps its ID in a first-party cookie by default. The option that stores nothing before consent shipped in mixpanel-browser 2.85.0 on November 6, 2026 (mixpanel-js 2.85.0 release notes).

mixpanel.init('YOUR_PROJECT_TOKEN', {
  consent_mode: 'require_consent',
})

// on accept
mixpanel.opt_in_tracking()

Before consent. 'require_consent' stores and sends nothing until opt_in_tracking(): no events, no profile or group updates, no feature flag fetches and no session recording. Version 2.87.0, released December 2, 2026, added 'exempt' for France’s CNIL audience-measurement exemption. It stores nothing and sends only page views, clicks, scrolls and page exits, one request each, with URLs cut to origin and path, the time rounded down to the hour, and only properties that can’t identify the visitor (mixpanel-js 2.87.0 release notes). With no ID on them, those add up to page views, not visitors or sessions.

On accept. opt_in_tracking() starts full tracking and, by default, tracks an $opt_in event (Mixpanel’s JavaScript SDK guide). Under 'require_consent', an identify() called before consent is held and applied at that point. Exempt events stay as they were sent, with nothing to tie them to the visitor.

The catch. Mixpanel’s JavaScript guide, checked December 3, 2026, still documents only opt_out_tracking_by_default, and that option writes to the device. It stores an opt-out flag at init(), under __mp_opt_in_out_ plus your project token in localStorage by default, and leaves the SDK’s own persistence on unless you also set opt_out_persistence_by_default (mixpanel-js opt-out source). Setting any consent_mode turns opt_out_tracking_by_default off, the mode is fixed at init, and an unrecognized value is treated as 'require_consent', so a typo collects nothing.

Amplitude: defer init()

Amplitude’s Browser SDK 2 keeps the device ID, user ID, session and opt-out flag in an AMP_ cookie that lasts 365 days by default. Its consent guide says to defer initialization when no cookie may exist before consent (Amplitude’s cookies and consent management guide).

import * as amplitude from '@amplitude/analytics-browser'

amplitude.track('Button Clicked')

// on accept
amplitude.init('AMPLITUDE_API_KEY')

Before consent. Until init() runs, the SDK has stored nothing, and the track() calls made before it wait in page memory (Amplitude’s core client source). Nothing reaches Amplitude, so there is nothing to count.

To count visitors before they answer instead, identityStorage: 'none' keeps identity in memory, and a reload creates a new device and session, so every page load counts as a new device. It covers identity only: the unsent-event queue is a separate option, storageProvider, which defaults to localStorage and needs an in-memory store of your own (Amplitude’s Browser SDK 2 configuration docs).

On accept. init() runs the waiting calls under the device ID it creates, so the accepting page’s events join the visitor. A visitor who leaves or reloads before accepting takes those calls with them.

The catch. optOut: true is not the setting it looks like. Amplitude says the SDK “may create cookies as soon as the SDK initializes, regardless of the user’s opt-out status”, and the opt-out flag itself is stored in the AMP_ cookie.

Matomo: requireCookieConsent

Matomo separates tracking consent from cookie consent, with one call for each (Matomo’s tracking and cookie consent guide).

var _paq = (window._paq = window._paq || [])
_paq.push(['requireCookieConsent'])
_paq.push(['trackPageView'])

// on accept
_paq.push(['rememberCookieConsentGiven'])

Before consent. requireCookieConsent keeps every tracking request going and sets no cookies, and the tracker has no localStorage code at all (Matomo’s 6.0.0 tracker source). requireConsent sends no request and sets no cookie until consent. Without a cookie, Matomo matches requests to visits by a config_id, a hash of the visitor’s operating system, browser, IP address and browser language that changes daily by default, looking back 30 minutes (Matomo’s unique and returning visitors FAQ). Matomo lists what that costs: unique, new and returning visitors become inaccurate, every cookieless visit counts as a new visitor, a conversion is credited only to the channel of the visit it happens in, and multi-attribution and cohort reports show no data (Matomo’s cookieless accuracy FAQ).

On accept. rememberCookieConsentGiven stores the answer in an mtm_cookie_consent cookie and turns the tracking cookies on; setCookieConsentGiven does the same without remembering, so you call it on every page. When the first request with a visitor ID finds no visit under that ID, Matomo may fall back to the config_id, so the pages viewed before the click can stay in the visit they belong to. Visits further back than the look-back stay separate.

The catch. requireCookieConsent still sends a request for every page, and Matomo’s own FAQ says that where consent is required, a visitor who rejects cookies also rejects JavaScript tracking (Matomo’s FAQ on tracking without cookie consent). Consent given through rememberCookieConsentGiven is remembered forever by default, except in Safari, where ITP cuts it to 7 days.

Consent Mode tells Google’s tags what the visitor agreed to. The default has to run on every page before config or any event (Google’s consent mode setup guide).

gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
})
gtag('config', 'G-XXXXXXXXXX')

// on accept
gtag('consent', 'update', { analytics_storage: 'granted' })

Before consent. It depends on the setup (Google’s consent mode overview). In the basic setup you block the tag until the visitor answers, and no data reaches Google, not even the consent state. In the advanced setup the tag loads and sends pings without cookies: a timestamp, the User-Agent, the referrer, the consent state, whether the URL carried an ad click, and a random number generated on each page load. GA4 can’t tell whether ten such page views came from ten users or one, and every page load sends its own first_visit and session_start. Behavioral modeling estimates the missing users and sessions once a property sends 1,000 denied events a day for 7 days and has 1,000 consented daily users on 7 of the previous 28 days, under the Blended reporting identity, and not in user explorer, cohort or user lifetime explorations or the BigQuery export (GA4 behavioral modeling for consent mode).

On accept. Call gtag('consent', 'update', ...) on the page where the visitor accepts, before any navigation, and the tag writes its cookies and sends events. One of those cookies is _ga, which lasts two years by default and is “used to distinguish users” (GA4 cookie usage). The pings sent before it carried no persistent ID, so they don’t join it.

The catch. Consent Mode doesn’t save the answer. You store it yourself and call the update on every later page. And the setup that sends nothing before consent is the one that gets no behavioral modeling: modeling needs the advanced setup, which sends those pings before anyone answers, while the basic setup leaves declined visitors out of GA4 altogether.

Checking what a tool stores

Open the page in a private window and leave the banner alone. Then, in the browser’s developer tools:

  • Cookies should hold nothing from the analytics script: no _ga, no AMP_, no _pk_id.
  • Local storage, session storage and IndexedDB should hold no key from the SDK, such as Mixpanel’s __mp_opt_in_out_ flag or Amplitude’s AMP_unsent_ queue.
  • The Network panel shows what goes out before the answer, and whether any ID repeats from one page load to the next.
  • A reload after accepting should show the ID persisting, which confirms the accept call reached the SDK.

The approaches behind these settings, from no identifier to a rotating one, are compared in cookieless tracking: what it is and how it works, and what a daily ID does to multi-day reports is in cookieless funnels and retention.

Sources, checked December 3, 2026: Pug Web SDK consent reference, PostHog: controlling data collection, PostHog cookieless tracking tutorial, PostHog persistence, posthog-js core source, Mixpanel JavaScript SDK guide, mixpanel-js 2.85.0 release notes, mixpanel-js 2.87.0 release notes, mixpanel-js opt-out source, Amplitude cookies and consent management, Amplitude Browser SDK 2 configuration, Amplitude Browser SDK core client source, Matomo tracking and cookie consent guide, Matomo unique and returning visitors FAQ, Matomo cookieless accuracy FAQ, Matomo FAQ on tracking without cookie consent, Matomo 6.0.0 tracker source, Google consent mode overview, Google consent mode setup guide, GA4 behavioral modeling for consent mode, GA4 cookie usage, EDPB Guidelines 2/2023.

Which analytics tools store nothing on the device before consent?

All six on this page can, with the right setting: Pug’s Web SDK by default, PostHog with cookieless_mode set to on_reject, Mixpanel with consent_mode set to require_consent or exempt (mixpanel-browser 2.85.0 and 2.87.0), Amplitude by calling init() only after consent, Matomo with requireCookieConsent or requireConsent, and Google Analytics 4 with Consent Mode’s analytics_storage denied. They differ in what they send before the visitor answers: PostHog, Mixpanel’s require_consent, Amplitude, Matomo’s requireConsent and GA4’s basic setup send nothing, while Pug, Mixpanel’s exempt mode, Matomo’s requireCookieConsent and GA4’s advanced setup send events with no stored ID.

Why is PostHog discarding my cookieless events?

Cookieless mode needs a project setting as well as the init option. Turn on Enable cookieless tracking under Settings, Project, Web analytics; while it is off, PostHog discards cookieless events and shows an ingestion warning.

Does PostHog’s opt_out_capturing_by_default store anything before consent?

It sends no events, but on its own it doesn’t turn off PostHog’s cookie and localStorage persistence: the SDK disables persistence for an opted-out visitor only when opt_out_persistence_by_default is true or cookieless_mode is on_reject. Feature flags also keep loading while the visitor is opted out, with requests that carry the distinct ID.

Does Mixpanel’s opt_out_tracking_by_default store anything?

Yes. It writes an opt-out flag at init, to localStorage by default or a cookie where localStorage is unavailable, and the SDK’s own persistence stays on unless you also set opt_out_persistence_by_default. From mixpanel-browser 2.85.0, consent_mode set to require_consent stores and sends nothing until opt_in_tracking().

Does Amplitude’s optOut option stop it setting cookies?

No. Amplitude says the Browser SDK may create cookies as soon as it initializes, whatever the opt-out status, and it keeps the opt-out flag itself in its AMP_ cookie. To have no Amplitude cookie before consent, call init() after the visitor accepts.

Do events from before consent join the visitor’s profile once they accept?

In Pug, no: granting consent starts a fresh ID and the cookieless events stay anonymous. GA4’s cookieless pings and Mixpanel’s exempt events carry no persistent ID, so they stay apart too. Amplitude sends the calls made before a deferred init() under the new device ID, so the accepting page’s events join. Matomo may match the first request after consent to the open visit by its config_id. PostHog with on_reject and Mixpanel with require_consent send nothing before the answer, though Mixpanel applies an identify() made before consent.

Add Pug’s Web SDK before your banner goes up

A plain init() stores nothing on the device until the visitor answers, and optInTracking() starts profiles when they accept. Pug Cloud is free up to 100k events a month, and self-hosting is free under AGPL-3.0.

Questions? Email hello@pug.sh