Connecting Craft CMS to Mixpanel
Craft is a developer-oriented CMS, usually built bespoke by an agency, which means the implementation is whatever that agency decided and nothing is standard. Mixpanel is a product analytics tool, not an ad platform, which means it has no attribution model of its own and will faithfully report whatever event schema you give it — including a bad one. The join between them succeeds or fails on one thing: whether the distinct_id reaches the Craft Commerce order before the conversion happens, because Mixpanel can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Craft Commerce orders in Mixpanel on the right distinct_id
Save the Mixpanel distinct_id to a custom field on the Craft Commerce cart, so the order-complete listener's server event joins the browsing. Call identify with the Craft user ID at login for account stores. Set $insert_id from the order reference, send refunds as their own event, and agree one purchase event name.
Mixpanel needs the purchase on the same distinct_id the browser used, and Craft gives you no default place to keep it. Read the ID from the Mixpanel JavaScript library when the cart is created and save it to a custom field on the cart. Since a Commerce cart is the same Order element that later completes, the server-side event fired from the order-complete listener can use it, and the purchase joins the browsing that led to it.
Decide what identifies a customer before launch. If the store has accounts, call identify with the Craft user ID at login and registration. If most orders are guest checkouts, the order email is the only stable key, and using it as an identity raises its own privacy questions to settle first. Set $insert_id from the order reference so a retried request or a re-saved order doesn't create a second purchase, and send refunds from Commerce transactions as their own event.
The common break is a purchase event fired from a cached Twig confirmation block, which sends nothing or the wrong order. If the product team already tracks Commerce events through another plugin, agree on one purchase event name before adding a server event beside it, or Mixpanel will treat the two as unrelated.
Craft → Mixpanel · what breaks
Why this join usually fails — Craft → Mixpanel
- 01
The distinct_id never reaches Craft
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
- 02
Every install is bespoke
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
- 03
One event schema, two teams, no agreement
Marketing names an event Purchase, the product team names it purchase_completed, and both are sent. Mixpanel treats them as unrelated, every funnel silently splits, and two teams spend a quarter arguing about which number is right when both are.
- 04
Nothing reconciles afterwards
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
Craft → Mixpanel · the fix
What working looks like — Craft → Mixpanel
The distinct_id on every order
Conversions arriving in Mixpanel
The event lands on the user profile and becomes available in funnels, retention and cohort analysis.
Reconciled against the source
Craft CMS's own records are the reference, not either dashboard.
Craft → Mixpanel · architecture
How Craft and Mixpanel actually connect
- 1
Craft CMS holds the truth
Craft installs are bespoke by nature. Establish how this particular build models a completed order before assuming anything transfers from another Craft site.
- 2
Mixpanel needs a click to match
Mixpanel needs a distinct_id, an event name and its properties. Events without a distinct_id are rejected; events with the wrong one land on a stranger's profile.
- 3
The identifier is the bridge
The distinct_id, captured at the visit and carried into the Craft Commerce order.
- 4
The event source decides reliability
Fire from the event listener in PHP rather than a Twig template, which may be cached.
- 5
Deduplication at the destination
Mixpanel deduplicates on $insert_id within a time window. Without it, a retried server request creates a second event, and because Mixpanel is where product decisions get made, that inflation ends up in a roadmap rather than in an ad report.
Craft → Mixpanel · normal or broken
Working vs. broken, side by side — Craft → Mixpanel
Normal, not a fault
The distinct_id present on the order
Visible on the record itself in Craft CMS, not merely captured somewhere on the site.
Sent from the Craft Commerce order-complete event
Deduplicated correctly
Mixpanel deduplicates on $insert_id within a time window. Without it, a retried server request creates a second event, and because Mixpanel is where product decisions get made, that inflation ends up in a roadmap rather than in an ad report.
Reconciles with the source
Mixpanel's count and Craft CMS's records agree within a few percent over a closed window.
Actually broken
The distinct_id missing on most records
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
Sent from the browser
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
Counted twice, or not at all
Marketing names an event Purchase, the product team names it purchase_completed, and both are sent. Mixpanel treats them as unrelated, every funnel silently splits, and two teams spend a quarter arguing about which number is right when both are.
Nobody has reconciled it
The dashboard shows a number and no one has compared it to Craft CMS.
Craft → Mixpanel · diagnose
Diagnostic order — Craft → Mixpanel
- 01
Count orders carrying the distinct_id
- 02
Follow one real conversion end to end
- 03
Read how this specific build handles order completion
Assumptions carried from another Craft project are the main source of wasted time here.
- 04
List every event name in the project and look for near-duplicates
Case differences, tense differences and synonyms are the usual finding, and they are cheap to fix before a year of data is built on them.
- 05
Read the match rate, not the success message
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
Craft → Mixpanel · prove
How it gets proven — Craft → Mixpanel
Against Craft CMS's own records, not against either platform's dashboard.
Source of truth
Craft Commerce's order records in your own database, filtered to completed.
- The distinct_id confirmed present on a live order.
- Purchase events reconciled per transaction against your billing system, with identity aliasing verified across the signup boundary.
- Order custom field confirmed populated on an order placed as an anonymous visitor through cache.
Craft → Mixpanel · free audit
What we check in the free audit
- Count orders carrying the distinct_id
- Follow one real conversion end to end
- Read how this specific build handles order completion
- List every event name in the project and look for near-duplicates
- Read the match rate, not the success message
Checked against
Craft Commerce's order records in your own database, filtered to completed.
Free30 minutesNo obligation
Craft → Mixpanel · when not to buy
When you don't need this — Craft → Mixpanel
- If Mixpanel already reports conversions that reconcile against Craft CMS's records within a few percent, this join is working and there is nothing to buy.
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
- If the original agency is still engaged, the fastest path is usually specifying the field and having them add the hook.
- If you already have the same events in a warehouse and nobody is running product analysis on them, adding Mixpanel adds a second source of truth rather than an answer.
Craft → Mixpanel · what we deliver
What gets built — Craft → Mixpanel
Identifier capture into Craft
Capture the identifier and store it as a custom field on the order through a Craft event listener, server-side.
Event source: the Craft Commerce order-complete event
Fire from the event listener in PHP rather than a Twig template, which may be cached.
Dispatch to Mixpanel
The Mixpanel ingestion API, posted server-side from your backend with the distinct_id and event properties.
Reversals where they exist
Refunds and cancelled orders are recorded against the order.
Written guarantee
95%+ tracking accuracy
Measured against Craft Commerce's order records in your own database, filtered to completed.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Craft → Mixpanel questions, answered
Listen for order completion in a Craft module, read the distinct_id you saved on the cart, and post the event to Mixpanel's ingestion API with the order reference as $insert_id.
Usually the server event uses the Craft user ID while browsing used an anonymous distinct_id that was never linked to it. Identify at login, or carry the browser's distinct_id on the cart.
Almost always because the distinct_id never reached the Craft Commerce order. Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look. Measure coverage before debugging the dispatch.
Mixpanel identifies people by distinct_id, which starts as an anonymous device value and should be aliased to your own user ID at signup. Getting that alias wrong is the single most common Mixpanel implementation failure: the anonymous pre-signup activity and the identified user become two separate people, and every funnel that crosses signup is broken.
The Craft Commerce order-complete event. Fire from the event listener in PHP rather than a Twig template, which may be cached.
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
More on Craft → Mixpanel
- Craft → Google AdsConnecting Craft CMS to Google Ads
- Craft → MetaConnecting Craft CMS to Meta Conversions API
- Craft → GA4Connecting Craft CMS to GA4
RELATED GUIDES
Where Craft → Mixpanel fits in the rest of your tracking
- Webflow → MixpanelConnecting Webflow to Mixpanel
- Drupal Commerce → MixpanelConnecting Drupal Commerce to Mixpanel
- AEM → MixpanelConnecting Adobe Experience Manager to Mixpanel
- Craft → AmplitudeConnecting Craft CMS to Amplitude
- Craft → Adobe AnalyticsConnecting Craft CMS to Adobe Analytics
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Statamic → MixpanelConnecting Statamic to Mixpanel
- Concrete CMS → MixpanelConnecting Concrete CMS to Mixpanel
Free · 30 min
Get Craft and Mixpanel joined properly
Free30 minutesNo obligation
