1,014 words, 49 clausesno date on the pageread 25/09/2026source
·Normally, PostHog stores some information about the user in their browser using a cookie. This approach is typical for analytics tools and enables user tracking across sessions, caching feature flag data, and more.
·There are some situations where you don't want to use cookies and do cookieless tracking instead. For example, when you have concerns about user privacy or to comply with regulation such as GDPR or HIPAA (or you just hate cookie banners).
·This tutorial shows how to configure PostHog's JavaScript Web SDK to do cookieless audience measurement.
·Note: When using cookies, PostHog stores data as a first-party cookie. We don't track users across different sites (like largely blocked third-party cookies do). It also means the same cookie works across subdomains like posthog.com and eu.posthog.com. Need analytics hosted in the EU?
·Note: Before configuring cookieless tracking, you need to enable "Cookieless server hash mode" in your PostHog project settings under Project Settings > Web analytics.
·If you never want to show a cookie banner, you can set the cookieless mode to "always". In this mode:
·To set this mode, add the following config option to your PostHog initialization:
·posthog.init("<ph_project_token>", { cookieless_mode: "always", api_host: "https://us.i.posthog.com", defaults: "2026-05-30",});
·This helps you comply with privacy regulations at the expense of a less detailed data capture.
·If you want to maintain the full tracking capability of PostHog, you'll need to show a cookie banner and only enable cookies when the user consents. To do this, you can set the cookieless mode to "on_reject", create a cookie banner, and connect it to PostHog's consent management methods.
·With this:
·To enable this mode, add the following config option to your PostHog initialization:
·posthog.init("<ph_project_token>", { cookieless_mode: "on_reject", api_host: "https://us.i.posthog.com", defaults: "2026-05-30",});
·Then connect PostHog to your cookie banner and display it when consent is pending:
·if (posthog.get_explicit_consent_status() === "pending") { // show a cookie banner}
·Finally, when the user makes a choice, opt them in or out:
·function handleCookieConsent(consent) { if (consent) { posthog.opt_in_capturing(); } else { posthog.opt_out_capturing(); }}
·This automatically sets the correct cookieless mode as well as changes the consent status to hide the cookie banner.
·When using cookieless tracking, PostHog doesn't store a distinct ID in the user's browser. Instead, PostHog generates this ID on our servers, using a hash:
·hash(team_id, daily_salt, ip_address, user_agent, hostname)
·A hash is an irreversible function, and a salt is a random value that changes daily which we delete once that day's events have been processed.
·This means that whilst the IP address and User Agent are Personal Data, the hash is not considered Personal Data because it is impossible to obtain any Personal Data from the hash.
·Nothing comes for free unfortunately. Limiting what PostHog can store in cookies has implications like:
·Read by 75,000+ founders and builders We'll share your email with Substack
·PostHog is the leading platform for building self-driving products. With a full suite of developer tools - AI observability, product analytics, session replay, feature flags, experiments, error tracking, logs, and more - PostHog captures all the context agents need to diagnose problems, uncover opportunities, and ship fixes. A data warehouse and CDP tie it all together, unifying that context into one source agents can read across. You can steer it all from Slack, the web app, the desktop (PostHog Desktop), or your own editor via the MCP.