Skip to main content
Magento → SegmentIntegration guide

Connecting Magento to Segment

Magento is self-hosted and endlessly customisable, which means every installation is different and full-page caching is always in the way. 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 Magento 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

Magento to Segment: Order Completed from the observer, once

Send Segment's Order Completed once, from the Magento order placement observer, with increment_id as order_id, SKUs at your ad catalog level, currency, and discounts and shipping as separate fields. Read anonymousId client-side at cart time, store it on the quote and order, identify with customer ID, and map credit memos to Order Refunded. Avoid duplicate extension events.

Segment on Magento should receive the order exactly once, from the server, because every connected destination inherits whatever it gets. Send Order Completed from the order placement observer following Segment's ecommerce spec: increment_id as order_id, each line's SKU as product_id at the same level your ad catalog feeds use, the order currency, and discounts and shipping as their own fields rather than folded into revenue.

Identity is the hard part on Magento. The anonymousId lives in the browser; full-page cache means you cannot print it into the page. Read it client-side at cart time, store it on the quote and copy it to the order. Identify with the Magento customer ID when they log in or register, and for guest orders send email as a trait so destinations that match on hashed email can still use it. Carry click identifiers and consent state as properties.

Credit memos map to Order Refunded with the same order_id, and partial refunds need the refunded products listed, not the full order. Check whether a Magento extension is already sending client-side ecommerce events; running it alongside your server event sends every order twice.

Magento → Segment · what breaks

Why this join usually fails — Magento → Segment

  1. 01

    The userId and anonymousId never reaches Magento

    Magento's full-page cache serves a stored render to the visitor, which means anything relying on dynamically rendered values can silently fail — and in Magento this has historically included serving one customer's cached block to another, which is a data problem as well as a tracking one.

  2. 02

    Full-page cache between the visitor and your code

    The page the customer saw is not the page your code assumed. This is the defining Magento tracking failure and it produces intermittent, hard-to-reproduce loss.

  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.

Magento → Segment · the fix

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

Magento → Segment · architecture

How Magento and Segment actually connect

  1. 1

    Magento holds the truth

    You own the database, so the truth is as good as the query. Pin down which order statuses count as revenue — processing, complete, or both — because that choice moves the number substantially.

  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 Magento order.

  4. 4

    The event source decides reliability

    Fire server-side from the observer rather than from the success page template, which is cached and may not execute anything.

  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.

Magento → Segment · normal or broken

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

Normal, not a fault

  • The userId and anonymousId present on the order

  • Sent from the Magento order placement observer

  • 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

    Magento's full-page cache serves a stored render to the visitor, which means anything relying on dynamically rendered values can silently fail — and in Magento this has historically included serving one customer's cached block to another, which is a data problem as well as a tracking one.

  • Sent from the browser

    The page the customer saw is not the page your code assumed. This is the defining Magento tracking failure and it produces intermittent, hard-to-reproduce loss.

  • 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

Magento → Segment · diagnose

Diagnostic order — Magento → Segment

  1. 01

    Count orders carrying the userId and anonymousId

  2. 02

    Follow one real conversion end to end

  3. 03

    Place a test order as an anonymous visitor through cache

    Not as an admin, which bypasses it. If the order data is missing on the cached path, caching is your cause.

  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.

Magento → Segment · prove

How it gets proven — Magento → Segment

Source of truth

Magento's sales order records in your own database, for the same window and order status set.

  • 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.
  • Order data confirmed populated on an order placed through a fully warmed cache.

Magento → Segment · free audit

What we check in the free audit

  • Count orders carrying the userId and anonymousId
  • Follow one real conversion end to end
  • Place a test order as an anonymous visitor through cache
  • Check identity resolution before checking anything downstream
  • Read the match rate, not the success message

Checked against

Magento's sales order records in your own database, for the same window and order status set.

Get my free conversion tracking audit

Free30 minutesNo obligation

Magento → Segment · when not to buy

When you don't need this — Magento → Segment

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the userId and anonymousId.
  • If your Magento build has heavy customisation by another team, scope their availability first — the build is usually blocked there.
  • 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.

Magento → Segment · what we deliver

What gets built — Magento → Segment

  • Identifier capture into Magento

    Capture the identifier and persist it as order data through an observer on order placement, server-side, so it never depends on what the cache served.

  • Event source: the Magento order placement observer

    Fire server-side from the observer rather than from the success page template, which is cached and may not execute anything.

  • 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

    Credit memos are recorded against the original order and should reduce the reported figure.

Written guarantee

95%+ tracking accuracy

Measured against Magento's sales order records in your own database, for the same window and order status set.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Magento → Segment questions, answered

Server-side from the order placement observer, with the browser anonymousId stored on the quote. Success pages behind full-page cache are unreliable.

Free · 30 min

Get Magento and Segment joined properly

Free30 minutesNo obligation