Skip to main content
Sitecore → PostHogIntegration guide

Connecting Sitecore to PostHog

Sitecore is enterprise digital experience software with its own personalisation and analytics stack, which frequently competes with rather than complements the measurement you are trying to build. 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 Sitecore contact and order 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

Sitecore headless and PostHog: same distinct_id from site to product

PostHog fits Sitecore sites fronting a product, including headless XM Cloud front ends where the library sits in the app. Call identify with your own user ID at signup so anonymous visits merge, never the Sitecore contact ID. Send subscription events from the product or billing system to the capture API with the same distinct_id and an event UUID.

PostHog is product analytics, so it fits a Sitecore site that sits in front of a product: a marketing site whose visitors sign up for an app, or a headless Sitecore front end built in Next.js on XM Cloud. In the headless case PostHog's JavaScript library goes into the front-end app rather than a Sitecore layout, and you can route ingestion through a path on your own domain so ad blockers treat it as first-party.

The join that makes PostHog worthwhile is the distinct_id carrying over from anonymous Sitecore visits to the signed-up product user. Call identify with your own user ID at signup or login so earlier pageviews merge with the account. Do not use Sitecore's contact ID as the distinct_id; it is scoped to Sitecore's tracker and changes when Sitecore merges contacts.

Server-side events from the product or billing system, such as subscription started or plan upgraded, should go to PostHog's capture API with the same distinct_id and an event UUID so retries do not duplicate. Sitecore's own goals do not need to be copied into PostHog; if marketing wants a page-level conversion, capture it once in PostHog and leave Sitecore's version to personalisation.

Sitecore → PostHog · what breaks

Why this join usually fails — Sitecore → PostHog

  1. 01

    The distinct_id never reaches Sitecore

    Sitecore's personalisation can vary page output per visitor, its analytics identity model is separate from any ad platform's, and enterprise deployments sit behind multiple caching and CDN layers.

  2. 02

    Two analytics systems answering different questions

    Sitecore's experience analytics and your ad platform reporting will never agree because they measure different things. Trying to reconcile them wastes weeks.

  3. 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.

  4. 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.

Sitecore → PostHog · the fix

What working looks like — Sitecore → PostHog

  • The distinct_id on every order

  • Conversions arriving in PostHog

    The event lands on the person profile and becomes available in insights, funnels and session replay.

  • Reconciled against the source

Sitecore → PostHog · architecture

How Sitecore and PostHog actually connect

  1. 1

    Sitecore holds the truth

    Sitecore's experience database tracks contacts and interactions for personalisation. It is not a conversion source for ad platforms and its numbers will not match theirs, by design.

  2. 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. 3

    The identifier is the bridge

    The distinct_id, captured at the visit and carried into the Sitecore contact and order.

  4. 4

    The event source decides reliability

    Send from the commerce layer. Sitecore's own goal and event tracking serves personalisation and should not be wired to ad platforms.

  5. 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.

Sitecore → PostHog · normal or broken

Working vs. broken, side by side — Sitecore → PostHog

Normal, not a fault

  • The distinct_id present on the order

  • Sent from your commerce system's order event

  • 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

    Sitecore's personalisation can vary page output per visitor, its analytics identity model is separate from any ad platform's, and enterprise deployments sit behind multiple caching and CDN layers.

  • Sent from the browser

    Sitecore's experience analytics and your ad platform reporting will never agree because they measure different things. Trying to reconcile them wastes weeks.

  • 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

Sitecore → PostHog · diagnose

Diagnostic order — Sitecore → PostHog

  1. 01

    Count orders carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Separate Sitecore's personalisation analytics from conversion measurement

    They are different systems for different purposes. Conflating them is the standard mistake in this stack.

  4. 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.

  5. 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.

Sitecore → PostHog · prove

How it gets proven — Sitecore → PostHog

Source of truth

Your commerce or CRM system — Sitecore's own analytics database answers a different question.

  • The distinct_id confirmed present on a live order.
  • Purchase events reconciled per transaction against your billing system, with ingestion lag checked over the same window.
  • Conversions confirmed sourced from the commerce system rather than from Sitecore's experience database.

Sitecore → PostHog · free audit

What we check in the free audit

  • Count orders carrying the distinct_id
  • Follow one real conversion end to end
  • Separate Sitecore's personalisation analytics from conversion measurement
  • Check ingestion health and disk before debugging any missing event
  • Read the match rate, not the success message

Checked against

Your commerce or CRM system — Sitecore's own analytics database answers a different question.

Get my free conversion tracking audit

Free30 minutesNo obligation

Sitecore → PostHog · when not to buy

When you don't need this — Sitecore → PostHog

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
  • If your Sitecore implementation is content-only with commerce elsewhere, work at the commerce layer entirely.
  • 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.

Sitecore → PostHog · what we deliver

What gets built — Sitecore → PostHog

  • Identifier capture into Sitecore

    Capture the identifier server-side in the application and persist it to the commerce order, keeping it separate from Sitecore's own contact identity model.

  • Event source: your commerce system's order event

    Send from the commerce layer. Sitecore's own goal and event tracking serves personalisation and should not be wired to ad platforms.

  • 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

    Handled at the commerce layer.

Written guarantee

95%+ tracking accuracy

Measured against Your commerce or CRM system — Sitecore's own analytics database answers a different question.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Sitecore → PostHog questions, answered

In the front-end application that renders the pages, usually a Next.js app, not inside Sitecore's content management side.

Free · 30 min

Get Sitecore and PostHog joined properly

Free30 minutesNo obligation