Connecting WooCommerce to PostHog
WooCommerce keeps the order in your own database, which is both the advantage and the reason nobody has wired it properly. 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 WooCommerce 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
WooCommerce to PostHog: the paid order joined to its browsing session
Save the PostHog distinct_id as WooCommerce order meta at checkout, then send the order from woocommerce_payment_complete with that ID, a UUID derived from the order ID, revenue, currency and line items. Identify by customer ID or guest billing email. Mask checkout inputs in session replay and confirm no payment fields are recorded.
PostHog's value to a WooCommerce store is seeing which browsing paths and product pages end in a paid order, with session replay of the checkout steps where people drop. That requires the server-side order event to land on the same person as the browsing, which means the PostHog distinct_id has to be saved as order meta during checkout.
Send the order from woocommerce_payment_complete through PostHog's PHP library or capture API with the stored distinct_id, the order ID as a property, a UUID derived from the order ID so retries do not duplicate, revenue, currency and line items. Identify the person once at checkout, with the WooCommerce customer ID for registered buyers or the billing email for guests, so later orders join the same person.
Session replay on WooCommerce needs care at checkout: billing fields, phone and address are personal data, and card fields may sit in gateway iframes. Mask checkout inputs in PostHog's replay settings and confirm nothing from the payment form is recorded. Watch caching as well: if the snippet's identity is lost between cached pages, each visit gets a new anonymous ID and orders appear disconnected from earlier browsing. Self-host only if you have a data residency reason.
WooCommerce → PostHog · what breaks
Why this join usually fails — WooCommerce → PostHog
- 01
The distinct_id never reaches WooCommerce
WooCommerce sites are usually the most heavily plugged-in of any platform. Caching plugins serve a static page to the visitor, optimization plugins defer or strip scripts, and consent plugins block them entirely. Any of the three will stop an identifier being captured, and they fail silently.
- 02
Caching and optimization plugins eat the tracking
The page the customer sees is not the page your code assumed. This is the most common cause of WooCommerce tracking that worked at launch and silently stopped after a plugin update.
- 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.
WooCommerce → PostHog · the fix
What working looks like — WooCommerce → 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
WooCommerce → PostHog · architecture
How WooCommerce and PostHog actually connect
- 1
WooCommerce holds the truth
You own the database, so the truth is exactly as good as the query you write against it. Pin the status set first — whether processing, completed, or both count as a conversion changes the number by a lot and is the source of most arguments.
- 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 WooCommerce order.
- 4
The event source decides reliability
Fire server-side from the PHP hook rather than from the thank-you page template. Page caching means the thank-you page cannot be relied on to execute anything, and on many stores it is served from cache to a paying customer.
- 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.
WooCommerce → PostHog · normal or broken
Working vs. broken, side by side — WooCommerce → PostHog
Normal, not a fault
The distinct_id present on the order
Sent from the woocommerce_payment_complete hook
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
WooCommerce sites are usually the most heavily plugged-in of any platform. Caching plugins serve a static page to the visitor, optimization plugins defer or strip scripts, and consent plugins block them entirely. Any of the three will stop an identifier being captured, and they fail silently.
Sent from the browser
The page the customer sees is not the page your code assumed. This is the most common cause of WooCommerce tracking that worked at launch and silently stopped after a plugin update.
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
WooCommerce → PostHog · diagnose
Diagnostic order — WooCommerce → PostHog
- 01
Count orders carrying the distinct_id
- 02
Follow one real conversion end to end
- 03
Check order meta on ten recent orders
Directly in the database or with a meta viewer. Then disable page caching for the checkout path and see whether coverage changes — if it does, caching is your cause.
- 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.
WooCommerce → PostHog · prove
How it gets proven — WooCommerce → PostHog
Source of truth
WooCommerce → Orders (or the wp_wc_order_stats table), for the same window and status set.
- 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 meta confirmed present on orders placed while full page caching was active.
WooCommerce → PostHog · free audit
What we check in the free audit
- Count orders carrying the distinct_id
- Follow one real conversion end to end
- Check order meta on ten recent orders
- Check ingestion health and disk before debugging any missing event
- Read the match rate, not the success message
Checked against
WooCommerce → Orders (or the wp_wc_order_stats table), for the same window and status set.
Free30 minutesNo obligation
WooCommerce → PostHog · when not to buy
When you don't need this — WooCommerce → PostHog
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
- If you run a small store with no caching layer and a single free plugin already reporting accurately, leave it alone.
- 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.
WooCommerce → PostHog · what we deliver
What gets built — WooCommerce → PostHog
Identifier capture into WooCommerce
Capture the click identifier and persist it as order meta on the order object with a small snippet in the theme's functions or a purpose-built plugin. Order meta lives in your own database, so it survives caching, plugin conflicts and the customer's browser.
Event source: the woocommerce_payment_complete hook
Fire server-side from the PHP hook rather than from the thank-you page template. Page caching means the thank-you page cannot be relied on to execute anything, and on many stores it is served from cache to a paying customer.
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
The refund hooks carry the order ID, so reversals are straightforward once the identifier is on the order.
Written guarantee
95%+ tracking accuracy
Measured against WooCommerce → Orders (or the wp_wc_order_stats table), for the same window and status set.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
WooCommerce → PostHog questions, answered
Save the PostHog distinct_id on the order at checkout and capture the purchase from the payment hook with PostHog's PHP library, using a UUID derived from the order ID.
Only with input masking on checkout fields. Confirm no billing details or payment data appear in recordings before enabling it on those pages.
Almost always because the distinct_id never reached the WooCommerce order. WooCommerce sites are usually the most heavily plugged-in of any platform. Caching plugins serve a static page to the visitor, optimization plugins defer or strip scripts, and consent plugins block them entirely. Any of the three will stop an identifier being captured, and they fail silently. 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.
The woocommerce_payment_complete hook. Fire server-side from the PHP hook rather than from the thank-you page template. Page caching means the thank-you page cannot be relied on to execute anything, and on many stores it is served from cache to a paying customer.
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 WooCommerce → PostHog
- WooCommerce Subscriptions → PostHogConnecting WooCommerce Subscriptions to PostHog
- WooCommerce → HubSpotConnecting WooCommerce to HubSpot
- WooCommerce → TikTokConnecting WooCommerce to TikTok Events API
RELATED GUIDES
Where WooCommerce → PostHog fits in the rest of your tracking
- Checkout Extensibility → PostHogConnecting Shopify Checkout Extensibility to PostHog
- Saleor → PostHogConnecting Saleor to PostHog
- Medusa → PostHogConnecting Medusa to PostHog
- WooCommerce → MixpanelConnecting WooCommerce to Mixpanel
- WooCommerce → Adobe AnalyticsConnecting WooCommerce to Adobe Analytics
- Furniture ecommerceConversion tracking for furniture ecommerce, measured after delivery
- Swell → PostHogConnecting Swell to PostHog
- OpenCart → PostHogConnecting OpenCart to PostHog
Free · 30 min
Get WooCommerce and PostHog joined properly
Free30 minutesNo obligation
