Skip to main content
Medusa → MixpanelIntegration guide

Connecting Medusa to Mixpanel

Medusa is a Node commerce engine you extend in your own codebase, which makes the conversion event a piece of application code — and therefore something that can be tested rather than hoped for. 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 Medusa 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

Medusa to Mixpanel: identity in cart metadata, events in code

Write the storefront's distinct_id into Medusa cart metadata and identify with the customer ID at login, then send the purchase from the payment-capture subscriber with the order ID as $insert_id. Keep only one purchase event name. Add an automated test asserting the outgoing payload's distinct_id, event name and $insert_id.

Mixpanel's distinct_id is set by the storefront SDK, and the Medusa backend has never seen it. Write it into cart metadata when the cart is created or first updated, and call identify with the Medusa customer ID when the shopper logs in or registers. Your payment-capture subscriber then sends the purchase with that distinct_id, so it lands on the same profile as the browsing.

Use the order ID as $insert_id. Subscribers can be retried on failure, and without an insert ID a retry becomes a second purchase in Mixpanel's funnels. Agree the event name with the product team before writing it: if the storefront already fires a purchase-like event from the confirmation page, remove it or make the backend event the only one, or Mixpanel will treat the two names as unrelated events.

Medusa gives you something most stores cannot have: an automated test for tracking. Write one that completes a cart with known metadata, captures a test payment and asserts that the outgoing Mixpanel payload has the right distinct_id, event name and $insert_id. It is a few lines in your own repo, and it catches the regression that otherwise shows up as a broken funnel a month after a storefront redesign.

Medusa → Mixpanel · what breaks

Why this join usually fails — Medusa → Mixpanel

  1. 01

    The distinct_id never reaches Medusa

    The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created.

  2. 02

    Firing on order placed rather than payment captured

    They are different events and the gap between them contains every failed and pending payment. Order-placed is the easier hook and the wrong one.

  3. 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.

  4. 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.

Medusa → Mixpanel · the fix

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

Medusa → Mixpanel · architecture

How Medusa and Mixpanel actually connect

  1. 1

    Medusa holds the truth

    Because you own the event handlers, the conversion can fire from the payment-captured event specifically rather than from whatever the frontend happened to render.

  2. 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. 3

    The identifier is the bridge

    The distinct_id, captured at the visit and carried into the Medusa order.

  4. 4

    The event source decides reliability

    Send orders at payment capture, at the paid total.

  5. 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.

Medusa → Mixpanel · normal or broken

Working vs. broken, side by side — Medusa → Mixpanel

Normal, not a fault

  • The distinct_id present on the order

  • Sent from a Medusa subscriber on order payment capture

  • 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

    The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created.

  • Sent from the browser

    They are different events and the gap between them contains every failed and pending payment. Order-placed is the easier hook and the wrong one.

  • 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

Medusa → Mixpanel · diagnose

Diagnostic order — Medusa → Mixpanel

  1. 01

    Count orders carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Check which event your subscriber listens to

    One line of code, and it decides whether you are counting orders or counting money.

  4. 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.

  5. 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.

Medusa → Mixpanel · prove

How it gets proven — Medusa → Mixpanel

Source of truth

Medusa orders by payment status, emitted from your own subscriber code.

  • 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.
  • Payment-captured orders reconciled against imported conversions.

Medusa → Mixpanel · free audit

What we check in the free audit

  • Count orders carrying the distinct_id
  • Follow one real conversion end to end
  • Check which event your subscriber listens to
  • List every event name in the project and look for near-duplicates
  • Read the match rate, not the success message

Checked against

Medusa orders by payment status, emitted from your own subscriber code.

Get my free conversion tracking audit

Free30 minutesNo obligation

Medusa → Mixpanel · when not to buy

When you don't need this — Medusa → Mixpanel

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
  • If every payment method you accept is instant, the two events nearly coincide and the distinction costs more than it returns.
  • 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.

Medusa → Mixpanel · what we deliver

What gets built — Medusa → Mixpanel

  • Identifier capture into Medusa

    Write the identifier into cart metadata at first touch so it is carried onto the order automatically at completion.

  • Event source: a Medusa subscriber on order payment capture

    Send orders at payment capture, at the paid total.

  • 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 emit their own event and should reverse.

Written guarantee

95%+ tracking accuracy

Measured against Medusa orders by payment status, emitted from your own subscriber code.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Medusa → Mixpanel questions, answered

From backend subscribers posting to Mixpanel's ingestion API, using the distinct_id the storefront stored in cart metadata. Fire purchases on payment capture, not order placement.

Free · 30 min

Get Medusa and Mixpanel joined properly

Free30 minutesNo obligation