Skip to main content
Statamic → GA4Integration guide

Connecting Statamic to GA4

Statamic is a flat-file CMS on Laravel, usually chosen by agencies for content sites where commerce is bolted on rather than central. GA4 is where the business goes to understand what happened, which makes an unattributed conversion there expensive in decisions rather than in ad spend. The join between them succeeds or fails on one thing: whether the GA4 client_id reaches the Statamic or Laravel order record before the conversion happens, because GA4 can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Statamic to GA4: client_id from the cookie into the Laravel order

Have your Laravel order listener read the _ga cookie at checkout, store the client_id and GA4 session_id on the order, then send purchase via Measurement Protocol with transaction_id set to the order ID and the items. Exclude checkout routes from Statamic's static cache, and do not also fire a gtag purchase from a confirmation template, since GA4 counts both.

GA4 is the destination least affected by Statamic's full static caching, because the _ga cookie is written by the GA4 tag in the browser, not by PHP. The gap is on the server side: your Laravel order listener has to read the _ga cookie from the checkout request, extract the client_id, and store it on the order, because the cached product pages never ran any PHP to hand it over.

Send purchase via Measurement Protocol from the Laravel order event with the client_id, the session_id from the GA4 session cookie, transaction_id set to your order ID, and the items. If your checkout or order routes are cached by accident, nothing runs at all; confirm they are excluded from static caching before debugging anything else.

Decide which side sends purchase. If a gtag purchase also fires from an order confirmation template, GA4 counts both, since Measurement Protocol has no deduplication. With full static caching, a cached confirmation page can even render the same stale transaction_id for every order. Moving purchase entirely to the server is the usual fix for this pair.

Statamic → GA4 · what breaks

Why this join usually fails — Statamic → GA4

  1. 01

    The GA4 client_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

    Everything lands under (direct)/(none)

    The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.

  4. 04

    Nothing reconciles afterwards

    GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.

Statamic → GA4 · the fix

What working looks like — Statamic → GA4

  • The GA4 client_id on every order

  • Conversions arriving in GA4

    Conversions appear in GA4 attributed to the original session's source and medium, so acquisition reporting reflects what actually drove revenue.

  • Reconciled against the source

Statamic → GA4 · architecture

How Statamic and GA4 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

    GA4 needs a click to match

    GA4 needs the client_id to attach a server event to the user and session that produced the click. Without it there is no attribution to inherit and the event is orphaned.

  3. 3

    The identifier is the bridge

    The GA4 client_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

    GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.

Statamic → GA4 · normal or broken

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

Normal, not a fault

  • The GA4 client_id present on the order

  • Sent from your Laravel application's order event

  • Deduplicated correctly

    GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.

  • Reconciles with the source

Actually broken

  • The GA4 client_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 classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.

  • Nobody has reconciled it

Statamic → GA4 · diagnose

Diagnostic order — Statamic → GA4

  1. 01

    Count orders carrying the GA4 client_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 whether server events carry a session and a source

    In GA4 Realtime or DebugView, find the event and look at its session and traffic source. A brand-new user with no source on every server event is the missing-client_id signature.

  5. 05

    Read the match rate, not the success message

    GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.

Statamic → GA4 · prove

How it gets proven — Statamic → GA4

Source of truth

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

  • The GA4 client_id confirmed present on a live order.
  • Server events confirmed in DebugView attaching to an existing session with the original traffic source intact.
  • Order data confirmed persisted on a purchase made while full static caching was active.

Statamic → GA4 · free audit

What we check in the free audit

  • Count orders carrying the GA4 client_id
  • Follow one real conversion end to end
  • Check whether full static caching is enabled
  • Check whether server events carry a session and a source
  • 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 → GA4 · when not to buy

When you don't need this — Statamic → GA4

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the GA4 client_id.
  • If commerce lives in a separate system entirely, work there — Statamic is the content layer.
  • GA4 is reporting, not bidding. If your problem is ad platform optimization, fix the ad platform destination first — GA4 will not change what any campaign does.

Statamic → GA4 · what we deliver

What gets built — Statamic → GA4

  • 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 GA4

    Measurement Protocol events with the client_id, session_id and the correct measurement ID and API secret, sent server-side.

  • 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 → GA4 questions, answered

Pageview tracking usually still works because GA4 runs in the browser, but any server-rendered purchase data in cached templates does not. Send purchase from your Laravel order event instead.

Free · 30 min

Get Statamic and GA4 joined properly

Free30 minutesNo obligation