Skip to main content
Shopify → PostHogIntegration guide

Connecting Shopify to PostHog

Shopify is the system of record for the order, and its admin numbers are the ones the business runs on. 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 Shopify 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

Shopify orders into PostHog on the same distinct_id as the visit

Read PostHog's distinct_id on the Shopify storefront, write it to a cart attribute, and send the purchase from the paid-order webhook through the capture API under that ID, with an event UUID derived from the order ID. Include revenue, currency, line items, discount code and a first-order flag, then identify with the Shopify customer ID.

PostHog's web snippet runs in a Shopify theme, so storefront funnels and session replay work; the checkout is where it stops. The order needs to land on the same person: read PostHog's distinct_id on the storefront, write it to a cart attribute before checkout, and send the purchase from the paid-order webhook through the capture API with that distinct_id. Then identify with the Shopify customer ID so later logged-in visits join the same person.

Derive the event UUID from the Shopify order ID, because Shopify retries webhooks and PostHog will otherwise store each retry. Send revenue and currency as properties, plus line items, discount code and whether this is the customer's first order. PostHog's value for a store is funnel and cohort analysis, and those properties are what the analysis slices on.

Expect a gap. Shoppers who block PostHog on the storefront have no distinct_id on their cart, so their orders arrive as a new person keyed on the customer. Count paid orders with and without the stored ID; that ratio is your real storefront coverage, and a reverse proxy on your own subdomain usually raises it. Session replay will never cover checkout pages, so funnel drop-off inside checkout has to come from Shopify's own checkout events.

Shopify → PostHog · what breaks

Why this join usually fails — Shopify → PostHog

  1. 01

    The distinct_id never reaches Shopify

    Shopify's checkout is locked down. Custom scripts on the checkout steps are not permitted on standard plans, and the old additional-scripts route is gone, so the identifier has to be captured on the storefront and carried into the order through cart or order attributes rather than read at the checkout itself.

  2. 02

    Checkout extensibility hides what you need

    Shopify deliberately restricts what runs during checkout. Setups that assumed free rein there broke when the platform moved to Checkout Extensibility, and many stores have been quietly under-reporting since.

  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.

Shopify → PostHog · the fix

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

Shopify → PostHog · architecture

How Shopify and PostHog actually connect

  1. 1

    Shopify holds the truth

    The order carries line items, discounts, shipping, tax, currency and the customer. Note which figure you intend to report — total, subtotal, or net of shipping and tax — because most mismatches between Shopify and an ad platform turn out to be two people comparing two different numbers.

  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 Shopify order.

  4. 4

    The event source decides reliability

    Send when Shopify says the order is paid, from your server. This also covers draft orders, POS, and the customer who closes the tab on the thank-you page — none of which a pixel on the order-status page will ever see.

  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.

Shopify → PostHog · normal or broken

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

Normal, not a fault

  • The distinct_id present on the order

  • Sent from the orders/paid webhook

  • 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

    Shopify's checkout is locked down. Custom scripts on the checkout steps are not permitted on standard plans, and the old additional-scripts route is gone, so the identifier has to be captured on the storefront and carried into the order through cart or order attributes rather than read at the checkout itself.

  • Sent from the browser

    Shopify deliberately restricts what runs during checkout. Setups that assumed free rein there broke when the platform moved to Checkout Extensibility, and many stores have been quietly under-reporting since.

  • 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

Shopify → PostHog · diagnose

Diagnostic order — Shopify → PostHog

  1. 01

    Count orders carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Open a recent paid order and read its note attributes

    If the identifier is not on the order, nothing downstream can attribute it. Check ten orders, not one — partial coverage is the normal failure, not total absence.

  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.

Shopify → PostHog · prove

How it gets proven — Shopify → PostHog

Source of truth

Shopify Admin → Orders, for the same window, in the same currency and on the same timezone.

  • 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 totals in Shopify Admin reconciled per order, not on the summed total, over a closed window.

Shopify → PostHog · free audit

What we check in the free audit

  • Count orders carrying the distinct_id
  • Follow one real conversion end to end
  • Open a recent paid order and read its note attributes
  • Check ingestion health and disk before debugging any missing event
  • Read the match rate, not the success message

Checked against

Shopify Admin → Orders, for the same window, in the same currency and on the same timezone.

Get my free conversion tracking audit

Free30 minutesNo obligation

Shopify → PostHog · when not to buy

When you don't need this — Shopify → PostHog

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
  • Shopify's own native channel integrations already cover simple single-currency stores adequately. If your admin numbers and platform numbers already agree, you do not need this.
  • 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.

Shopify → PostHog · what we deliver

What gets built — Shopify → PostHog

  • Identifier capture into Shopify

    Capture the click identifier on the storefront, write it to a cart attribute so it becomes an order note attribute, and read it back server-side from the order. That path survives the checkout domain hop that breaks cookie-based approaches.

  • Event source: the orders/paid webhook

    Send when Shopify says the order is paid, from your server. This also covers draft orders, POS, and the customer who closes the tab on the thank-you page — none of which a pixel on the order-status page will ever see.

  • 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

    refunds/create fires with the original order reference, so refunds and cancellations can be reversed at the destination.

Written guarantee

95%+ tracking accuracy

Measured against Shopify Admin → Orders, for the same window, in the same currency and on the same timezone.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Shopify → PostHog questions, answered

Not with the web snippet on checkout pages. Send the purchase server-side from the paid-order webhook using the distinct_id stored on the cart.

Free · 30 min

Get Shopify and PostHog joined properly

Free30 minutesNo obligation