Connecting Cookiebot to PostHog
Cookiebot scans your site and blocks scripts automatically by category, which means it can stop a tag you rely on without anybody deciding to. PostHog can be self-hosted, which changes the calculus entirely: the data stays on infrastructure you control, and so does the responsibility for everything that goes wrong with it. The join between them succeeds or fails on one thing: whether the distinct_id reaches the Cookiebot consent state before the conversion happens, because PostHog can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Cookiebot and PostHog behind a reverse proxy: is it being gated?
A PostHog instance proxied through your own subdomain may escape Cookiebot's scanner and run for everyone. Wire it explicitly: initialize posthog-js with memory-only persistence and call opt_in_capturing or opt_out_capturing from Cookiebot.consent.statistics, deciding session replay separately. Alias anonymous IDs to backend user IDs only when stored consent allows.
Many teams route PostHog through their own subdomain so ad blockers do not stop it. Cookiebot's automatic blocking works by recognising scripts and domains, and a proxied PostHog on your own subdomain may not be recognised at all. Check the scan report. If it is missing or unclassified, PostHog is running for every visitor whatever they chose, and your product numbers look better than your consent rate should allow. That is a compliance gap, not good fortune.
Rather than letting the scanner decide, wire PostHog to Cookiebot explicitly. Initialise posthog-js in memory-only persistence, so nothing is written to cookies or local storage, and call opt_in_capturing when Cookiebot.consent.statistics turns true, or opt_out_capturing on decline, depending on what your counsel says decliners may receive. Session replay deserves its own decision; it records far more than a pageview.
Server-side events from your backend, sent to the capture API with your own user ID as distinct_id, are separate from the banner. A signed-in customer's subscription event in your database is your record. Whether it should be joined to their anonymous browsing in PostHog depends on whether that browsing was captured with consent, so only alias the anonymous ID to the user ID when the stored choice allows it.
Cookiebot → PostHog · what breaks
Why this join usually fails — Cookiebot → PostHog
- 01
The distinct_id never reaches Cookiebot
Scripts are blocked before execution, so an identifier-capture script placed in a blocked category never runs at all.
- 02
Automatic classification blocking the wrong script
The scanner decides what each script is. It gets things wrong, and a first-party capture script filed under marketing will be blocked for every visitor who declines marketing — including many who would have accepted what it actually does.
- 03
Self-hosting the analytics and the outage together
The advantage of owning the pipeline is that nothing blocks it. The cost is that when the ingestion instance fills its disk on a Saturday, the events are gone and nobody is paged. Hosted tools fail differently and more visibly.
- 04
Nothing reconciles afterwards
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
Cookiebot → PostHog · the fix
What working looks like — Cookiebot → PostHog
The distinct_id on every consent record
Conversions arriving in PostHog
The event lands on the person profile and becomes available in insights, funnels and session replay.
Reconciled against the source
Cookiebot → PostHog · architecture
How Cookiebot and PostHog actually connect
- 1
Cookiebot holds the truth
Automatic blocking classifies scripts by scanning. A misclassified tag gets blocked for visitors who would have consented, and the loss is invisible because everything looks configured correctly.
- 2
PostHog needs a click to match
PostHog needs a distinct_id, an event name and its properties. Self-hosted instances additionally need the ingestion endpoint reachable and the project API key correct, which is a class of failure hosted tools do not have.
- 3
The identifier is the bridge
The distinct_id, captured at the visit and carried into the Cookiebot consent state.
- 4
The event source decides reliability
Send consented conversions, with the consent rate and the blocked-category mix reported alongside.
- 5
Deduplication at the destination
PostHog deduplicates on the event UUID where supplied. Without one, a retried batch duplicates, and on a self-hosted instance there is no vendor support desk to notice it for you.
Cookiebot → PostHog · normal or broken
Working vs. broken, side by side — Cookiebot → PostHog
Normal, not a fault
The distinct_id present on the consent record
Sent from your order system, gated on consent
Deduplicated correctly
PostHog deduplicates on the event UUID where supplied. Without one, a retried batch duplicates, and on a self-hosted instance there is no vendor support desk to notice it for you.
Reconciles with the source
Actually broken
The distinct_id missing on most records
Scripts are blocked before execution, so an identifier-capture script placed in a blocked category never runs at all.
Sent from the browser
The scanner decides what each script is. It gets things wrong, and a first-party capture script filed under marketing will be blocked for every visitor who declines marketing — including many who would have accepted what it actually does.
Counted twice, or not at all
The advantage of owning the pipeline is that nothing blocks it. The cost is that when the ingestion instance fills its disk on a Saturday, the events are gone and nobody is paged. Hosted tools fail differently and more visibly.
Nobody has reconciled it
Cookiebot → PostHog · diagnose
Diagnostic order — Cookiebot → PostHog
- 01
Count consent records carrying the distinct_id
- 02
Follow one real conversion end to end
- 03
Read the scan results and check how each of your scripts was classified
This takes ten minutes and it is the first thing to check when conversions drop after a CMP deployment.
- 04
Check ingestion health and disk before debugging any missing event
On self-hosted instances the answer is infrastructure far more often than it is instrumentation.
- 05
Read the match rate, not the success message
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
Cookiebot → PostHog · prove
How it gets proven — Cookiebot → PostHog
Source of truth
Your order system, with the visitor's consent categories recorded at the time of the event.
- The distinct_id confirmed present on a live consent record.
- Purchase events reconciled per transaction against your billing system, with ingestion lag checked over the same window.
- Consented conversions reconciled against imported figures, with script classifications verified against what they collect.
Cookiebot → PostHog · free audit
What we check in the free audit
- Count consent records carrying the distinct_id
- Follow one real conversion end to end
- Read the scan results and check how each of your scripts was classified
- Check ingestion health and disk before debugging any missing event
- Read the match rate, not the success message
Checked against
Your order system, with the visitor's consent categories recorded at the time of the event.
Free30 minutesNo obligation
Cookiebot → PostHog · when not to buy
When you don't need this — Cookiebot → PostHog
- Measure identifier coverage yourself first — pull your last hundred consent records and count how many carry the distinct_id.
- If you have no legal requirement for consent in your markets, adding automatic blocking will cost you data for no compliance benefit.
- If you have no reason to keep the data on your own infrastructure and no team to run it, the hosted product removes the only real downside of this one.
Cookiebot → PostHog · what we deliver
What gets built — Cookiebot → PostHog
Identifier capture into Cookiebot
Verify which category your capture script is classified into, and keep capture in a category that matches what you actually collect.
Event source: your order system, gated on consent
Send consented conversions, with the consent rate and the blocked-category mix reported alongside.
Dispatch to PostHog
The PostHog capture API, posted server-side from your backend to your own instance or to PostHog Cloud.
Reversals where they exist
Consent withdrawal stops future sends.
Written guarantee
95%+ tracking accuracy
Measured against Your order system, with the visitor's consent categories recorded at the time of the event.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Cookiebot → PostHog questions, answered
Possibly not. Automatic blocking relies on recognising scripts, and a proxied PostHog may go unrecognised. Check the scan report and gate PostHog explicitly on Cookiebot's statistics consent.
Start PostHog with memory-only persistence and call opt_in_capturing when Cookiebot reports statistics consent. Confirm with counsel what may be captured before a choice is made.
Almost always because the distinct_id never reached the Cookiebot consent state. Scripts are blocked before execution, so an identifier-capture script placed in a blocked category never runs at all. Measure coverage before debugging the dispatch.
PostHog identifies by distinct_id with an alias call to merge anonymous and identified users. On a self-hosted instance you also control the ingestion endpoint, which means the identifier survives ad blockers that would kill a third-party pixel — one of the few genuine technical advantages available to a first-party setup.
Your order system, gated on consent. Send consented conversions, with the consent rate and the blocked-category mix reported alongside.
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
More on Cookiebot → PostHog
- Stripe → PostHogConnecting Stripe to PostHog
- PayPal → PostHogConnecting PayPal to PostHog
- Shopify → PostHogConnecting Shopify to PostHog
RELATED GUIDES
Where Cookiebot → PostHog fits in the rest of your tracking
- iubenda → PostHogConnecting iubenda to PostHog
- Termly → PostHogConnecting Termly to PostHog
- OneTrust → PostHogConnecting OneTrust to PostHog
- Cookiebot → MatomoConnecting Cookiebot to Matomo
- Cookiebot → GA4Connecting Cookiebot to GA4
- SaaSConversion tracking for SaaS, from signup through to the payment that matters
- Osano → PostHogConnecting Osano to PostHog
- Complianz → PostHogConnecting Complianz to PostHog
Free · 30 min
Get Cookiebot and PostHog joined properly
Free30 minutesNo obligation
