Skip to main content
Medusa → SegmentIntegration guide

Connecting Medusa to Segment

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. Segment is a customer data platform rather than an ad network, so sending to it is not about matching a conversion — it is about putting one clean event where every other destination can read it. The join between them succeeds or fails on one thing: whether the userId and anonymousId reaches the Medusa order before the conversion happens, because Segment can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Medusa to Segment: Order Completed on payment capture

Check your Medusa version's Segment plugin or analytics provider, and make sure Order Completed fires at payment capture, not placement. Store analytics.js anonymousId, click IDs and consent in cart metadata, send userId once known, derive messageId from the order ID, and send Order Refunded. Test the payload, since mistakes fan out everywhere.

Medusa has offered Segment support before: version 1 had a Segment plugin, and newer versions have an analytics module with pluggable providers, so check what your version supports before writing your own client. Whichever you use, confirm which Medusa event it sends on. An integration that sends Order Completed when the order is placed reports pending and failed payments to every destination in your workspace; the event you want is payment captured.

For identity, write the anonymousId from the storefront's analytics.js into cart metadata along with click IDs and the visitor's consent state, and use the Medusa customer ID as userId once the shopper is known. The backend sends Order Completed with both, a messageId derived from the order ID, and a products array following Segment's ecommerce spec. Send Order Refunded from a refund subscriber, and let destinations filter on the stored consent state.

Because Segment fans out, a mistake here repeats everywhere: a wrong currency or a doubled event appears in the warehouse, Meta and Google Ads at once. Medusa lets you write a test that captures a payment and asserts the payload, and with Segment in the middle that test is worth more than usual.

Medusa → Segment · what breaks

Why this join usually fails — Medusa → Segment

  1. 01

    The userId and anonymousId 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 bad event multiplied across every destination

    Segment's value is fan-out, which is also its risk. An inconsistent identity or a duplicated event does not break one report — it breaks every connected tool simultaneously, and tracing it back is harder than debugging a direct integration.

  4. 04

    Nothing reconciles afterwards

    Segment's debugger shows events arriving and which destinations accepted them. Arriving is not the test — check a destination you care about and confirm the event landed there with the identity intact, then reconcile against your own records.

Medusa → Segment · the fix

What working looks like — Medusa → Segment

  • The userId and anonymousId on every order

  • Conversions arriving in Segment

    Events land in Segment and forward to every connected destination, warehouse included, on one shared definition.

  • Reconciled against the source

Medusa → Segment · architecture

How Medusa and Segment 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

    Segment needs a click to match

    Segment needs a consistent identity model — the same userId everywhere, an alias when an anonymous visitor becomes known, and event names that follow one spec. Feeding it inconsistent identities pushes the mess to every connected destination at once.

  3. 3

    The identifier is the bridge

    The userId and anonymousId, 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

    Segment deduplicates on messageId within a window. Because it fans out to many destinations, a duplicate here becomes a duplicate everywhere, which makes idempotent messageIds more important than in any single-destination integration.

Medusa → Segment · normal or broken

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

Normal, not a fault

  • The userId and anonymousId present on the order

  • Sent from a Medusa subscriber on order payment capture

  • Deduplicated correctly

    Segment deduplicates on messageId within a window. Because it fans out to many destinations, a duplicate here becomes a duplicate everywhere, which makes idempotent messageIds more important than in any single-destination integration.

  • Reconciles with the source

Actually broken

  • The userId and anonymousId 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

    Segment's value is fan-out, which is also its risk. An inconsistent identity or a duplicated event does not break one report — it breaks every connected tool simultaneously, and tracing it back is harder than debugging a direct integration.

  • Nobody has reconciled it

Medusa → Segment · diagnose

Diagnostic order — Medusa → Segment

  1. 01

    Count orders carrying the userId and anonymousId

  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

    Check identity resolution before checking anything downstream

    If anonymousId is never aliased to userId, every destination sees two people where there is one, and no downstream fix helps.

  5. 05

    Read the match rate, not the success message

    Segment's debugger shows events arriving and which destinations accepted them. Arriving is not the test — check a destination you care about and confirm the event landed there with the identity intact, then reconcile against your own records.

Medusa → Segment · prove

How it gets proven — Medusa → Segment

Source of truth

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

  • The userId and anonymousId confirmed present on a live order.
  • An anonymous session confirmed aliased to a known user, with the event visible in at least one downstream destination.
  • Payment-captured orders reconciled against imported conversions.

Medusa → Segment · free audit

What we check in the free audit

  • Count orders carrying the userId and anonymousId
  • Follow one real conversion end to end
  • Check which event your subscriber listens to
  • Check identity resolution before checking anything downstream
  • 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 → Segment · when not to buy

When you don't need this — Medusa → Segment

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the userId and anonymousId.
  • If every payment method you accept is instant, the two events nearly coincide and the distinction costs more than it returns.
  • If you send to one or two destinations, Segment is infrastructure you do not need — direct integrations are simpler and cheaper. It earns its place at genuine fan-out.

Medusa → Segment · what we deliver

What gets built — Medusa → Segment

  • 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 Segment

    Server-side track and identify calls with a stable messageId, consistent userId, and the click identifier carried as a trait or property.

  • 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 → Segment questions, answered

Medusa v1 had a Segment plugin; for newer versions, check the analytics module's providers or send from your own subscriber. Either way, confirm it fires on payment capture.

Free · 30 min

Get Medusa and Segment joined properly

Free30 minutesNo obligation