Skip to main content
Statamic → PostHogIntegration guide

Connecting Statamic to PostHog

Statamic is a flat-file CMS on Laravel, usually chosen by agencies for content sites where commerce is bolted on rather than central. 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 Statamic or Laravel order record 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

Statamic marketing site and PostHog: experiments without PHP

Set PostHog's cookie on the parent domain so the Statamic site and the app share one distinct_id, and identify only at app sign-up. Send form submissions from a Laravel listener with the distinct_id read from a hidden field. Feature flags evaluated in Antlers templates freeze under static caching, so evaluate them client-side or exclude experiment pages.

PostHog on a Statamic site is usually the marketing half of a product already in PostHog, and the goal is one distinct_id from first visit to in-app activation. Set PostHog's cookie on the parent domain so the marketing site and the app share it, and call identify only in the app at sign-up, so anonymous Statamic visits merge into the user rather than creating a second person.

Experiments are where Statamic needs care. A feature flag evaluated in an Antlers template does not run when the page is served from full static cache, so every visitor gets whatever variant the cache built. Evaluate flags client-side with the JavaScript library, accept a brief swap on load or hide the swapped element until flags resolve, or exclude experiment pages from the static cache.

Server-side events from Statamic are mostly form submissions, a demo request or newsletter sign-up, sent from a Laravel listener with the distinct_id read from PostHog's cookie through a hidden field. Without that ID the event lands on a new person and the funnel from article to demo request breaks at the last step.

Statamic → PostHog · what breaks

Why this join usually fails — Statamic → PostHog

  1. 01

    The distinct_id never reaches Statamic

    Statamic's static caching serves pre-rendered files with no PHP execution at all, which means anything expecting server-side rendering per request simply does not run.

  2. 02

    Static caching bypassing PHP entirely

    Statamic's full static caching serves a file from disk. No PHP runs, so nothing dynamic happens — and this is invisible because the page looks perfect.

  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.

Statamic → PostHog · the fix

What working looks like — Statamic → 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

Statamic → PostHog · architecture

How Statamic and PostHog actually connect

  1. 1

    Statamic holds the truth

    Because Statamic sits on Laravel, the commercial record is usually a database table your developers defined. That is the source of truth and it is fully under your control.

  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 Statamic or Laravel order record.

  4. 4

    The event source decides reliability

    Fire from the application event. Static caching means the template that rendered the page may never have executed anything.

  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.

Statamic → PostHog · normal or broken

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

Normal, not a fault

  • The distinct_id present on the order

  • Sent from your Laravel application'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

    Statamic's static caching serves pre-rendered files with no PHP execution at all, which means anything expecting server-side rendering per request simply does not run.

  • Sent from the browser

    Statamic's full static caching serves a file from disk. No PHP runs, so nothing dynamic happens — and this is invisible because the page looks perfect.

  • 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

Statamic → PostHog · diagnose

Diagnostic order — Statamic → PostHog

  1. 01

    Count orders carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Check whether full static caching is enabled

    If it is, any per-request logic in a template is not running and never was.

  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.

Statamic → PostHog · prove

How it gets proven — Statamic → PostHog

Source of truth

Whatever your Laravel application persists — Statamic's flat files hold content, not transactions.

  • 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.
  • Order data confirmed persisted on a purchase made while full static caching was active.

Statamic → PostHog · free audit

What we check in the free audit

  • Count orders carrying the distinct_id
  • Follow one real conversion end to end
  • Check whether full static caching is enabled
  • Check ingestion health and disk before debugging any missing event
  • Read the match rate, not the success message

Checked against

Whatever your Laravel application persists — Statamic's flat files hold content, not transactions.

Get my free conversion tracking audit

Free30 minutesNo obligation

Statamic → PostHog · when not to buy

When you don't need this — Statamic → PostHog

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
  • If commerce lives in a separate system entirely, work there — Statamic is the content layer.
  • 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.

Statamic → PostHog · what we deliver

What gets built — Statamic → PostHog

  • Identifier capture into Statamic

    Capture the identifier and persist it through a Laravel event listener into your own order table, entirely outside the static cache path.

  • Event source: your Laravel application's order event

    Fire from the application event. Static caching means the template that rendered the page may never have executed anything.

  • 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

    Whatever your application defines as a refund.

Written guarantee

95%+ tracking accuracy

Measured against Whatever your Laravel application persists — Statamic's flat files hold content, not transactions.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Statamic → PostHog questions, answered

Only if evaluated client-side. Server-side evaluation in templates does not run on fully cached pages.

Free · 30 min

Get Statamic and PostHog joined properly

Free30 minutesNo obligation