Connecting Drupal Commerce to Mixpanel
Drupal Commerce is self-hosted commerce inside a CMS built for complex content, which means the store is one part of a much larger site you fully control. 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 Drupal 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
Drupal Commerce to Mixpanel: identify at account creation
Call identify with the Drupal uid when an account is created at checkout, not just at login, so anonymous history merges. Send purchases server-side on order placement with the distinct_id from a hidden checkout field and $insert_id derived from the order ID. Add content properties to page events and keep one event name list.
Mixpanel identity breaks where a shopper's status changes, and Drupal Commerce has two such points: the login-or-guest choice at the start of checkout, and the optional account creation at completion. If you call identify only on login, everyone who registers at checkout completion stays anonymous in Mixpanel, and their next visit as a logged-in customer starts a second profile. Call identify with the Drupal uid when the account is created, in the same request, so the anonymous checkout history merges.
Send the purchase server-side when the order is placed, with the distinct_id written from the browser into a hidden checkout field, since a cached page cannot embed it. Use $insert_id derived from the order ID: if queue processing overlaps, the same item can be handled twice, and Mixpanel needs that ID to drop the duplicate.
Product analysis is where Drupal's content-plus-commerce shape pays off. Send the content that preceded the purchase, such as node type, guide or landing page, as properties on page events, and you can see which content leads to orders. Keep event names in one agreed list. Drupal sites often run a contributed module's events and a developer's custom ones side by side, which is Mixpanel's near-duplicate event problem in its most common form.
Drupal Commerce → Mixpanel · what breaks
Why this join usually fails — Drupal Commerce → Mixpanel
- 01
The distinct_id never reaches Drupal Commerce
Drupal's internal page cache and any reverse proxy in front of it serve stored renders, so anything relying on dynamically rendered values fails intermittently. Multilingual and multi-site installs add further paths where the capture code may simply not run.
- 02
Configurable workflow states nobody agreed on
Drupal Commerce lets each install define its own order states. Two people reporting on the same store routinely count different states and never reconcile.
- 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.
Drupal Commerce → Mixpanel · the fix
What working looks like — Drupal Commerce → 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
Drupal Commerce → Mixpanel · architecture
How Drupal Commerce and Mixpanel actually connect
- 1
Drupal Commerce holds the truth
You own the database, so the truth is exactly as good as the query. Pin down which order states count as revenue before comparing anything — Drupal's workflow states are configurable per install, so no two sites agree by default.
- 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 Drupal Commerce order.
- 4
The event source decides reliability
Fire server-side from the hook rather than the checkout completion template, which is cacheable and may not execute anything.
- 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.
Drupal Commerce → Mixpanel · normal or broken
Working vs. broken, side by side — Drupal Commerce → Mixpanel
Normal, not a fault
The distinct_id present on the order
Sent from the Drupal Commerce order placement hook
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
Actually broken
The distinct_id missing on most records
Drupal's internal page cache and any reverse proxy in front of it serve stored renders, so anything relying on dynamically rendered values fails intermittently. Multilingual and multi-site installs add further paths where the capture code may simply not run.
Sent from the browser
Drupal Commerce lets each install define its own order states. Two people reporting on the same store routinely count different states and never reconcile.
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
Drupal Commerce → Mixpanel · diagnose
Diagnostic order — Drupal Commerce → Mixpanel
- 01
Count orders carrying the distinct_id
- 02
Follow one real conversion end to end
- 03
List the order states in use and agree which count as revenue
Do this before any technical work — it resolves more Drupal Commerce disputes than any code change.
- 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.
Drupal Commerce → Mixpanel · prove
How it gets proven — Drupal Commerce → Mixpanel
Source of truth
Drupal's commerce_order records in your own database, filtered to completed states.
- 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 field data confirmed populated on an order placed through a fully warmed cache as an anonymous visitor.
Drupal Commerce → Mixpanel · free audit
What we check in the free audit
- Count orders carrying the distinct_id
- Follow one real conversion end to end
- List the order states in use and agree which count as revenue
- List every event name in the project and look for near-duplicates
- Read the match rate, not the success message
Checked against
Drupal's commerce_order records in your own database, filtered to completed states.
Free30 minutesNo obligation
Drupal Commerce → Mixpanel · when not to buy
When you don't need this — Drupal Commerce → Mixpanel
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
- If your Drupal site is content-only with commerce elsewhere, work at the commerce system instead — this is the wrong layer.
- 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.
Drupal Commerce → Mixpanel · what we deliver
What gets built — Drupal Commerce → Mixpanel
Identifier capture into Drupal Commerce
Capture the identifier and persist it as order field data through a hook on order placement, server-side, so it never depends on what the cache served.
Event source: the Drupal Commerce order placement hook
Fire server-side from the hook rather than the checkout completion template, which is cacheable and may not execute anything.
Dispatch to Mixpanel
The Mixpanel ingestion API, posted server-side from your backend with the distinct_id and event properties.
Reversals where they exist
Order state transitions to refunded or cancelled are recorded and can drive reversals.
Written guarantee
95%+ tracking accuracy
Measured against Drupal's commerce_order records in your own database, filtered to completed states.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Drupal Commerce → Mixpanel questions, answered
The anonymous checkout and the logged-in user were never linked. Call identify with the Drupal user ID when the account is created at checkout, and send the anonymous distinct_id with the server-side purchase.
The server, from the order placement event. The completion page is cacheable and may not run JavaScript reliably; use the browser SDK for page and cart events.
Almost always because the distinct_id never reached the Drupal Commerce order. Drupal's internal page cache and any reverse proxy in front of it serve stored renders, so anything relying on dynamically rendered values fails intermittently. Multilingual and multi-site installs add further paths where the capture code may simply not run. 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 Drupal Commerce order placement hook. Fire server-side from the hook rather than the checkout completion template, which is cacheable and may not execute anything.
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 Drupal Commerce → Mixpanel
- Drupal Commerce → Google AdsConnecting Drupal Commerce to Google Ads
- Drupal Commerce → MetaConnecting Drupal Commerce to Meta Conversions API
- Drupal Commerce → GA4Connecting Drupal Commerce to GA4
RELATED GUIDES
Where Drupal Commerce → Mixpanel fits in the rest of your tracking
- Umbraco → MixpanelConnecting Umbraco to Mixpanel
- Webflow → MixpanelConnecting Webflow to Mixpanel
- AEM → MixpanelConnecting Adobe Experience Manager to Mixpanel
- Drupal Commerce → Adobe AnalyticsConnecting Drupal Commerce to Adobe Analytics
- Drupal Commerce → MatomoConnecting Drupal Commerce to Matomo
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Statamic → MixpanelConnecting Statamic to Mixpanel
- Sanity → MixpanelConnecting Sanity to Mixpanel
Free · 30 min
Get Drupal Commerce and Mixpanel joined properly
Free30 minutesNo obligation
