Skip to main content
Drupal Commerce → AmplitudeIntegration guide

Connecting Drupal Commerce to Amplitude

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. Amplitude is built around behavioural cohorts, which makes the identity resolution and the event taxonomy load-bearing in a way they never are for an ad pixel. The join between them succeeds or fails on one thing: whether the user ID and device ID pair reaches the Drupal Commerce order before the conversion happens, because Amplitude can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Drupal Commerce to Amplitude: guest orders and the device ID

Write Amplitude's device ID into a hidden checkout field, not cached HTML, and store it on the Drupal Commerce order. On the chosen workflow transition, send the purchase with that device ID, the uid as user_id when known, and per-line price, quantity and SKU productId. Send negative revenue on cancellation.

Drupal Commerce lets shoppers check out as guests, which leaves the order with an email but no Drupal user. For Amplitude that matters more than usual: a server-side purchase without the browser's device ID or a user ID becomes an orphan, and your checkout funnel shows plenty of people who started and nobody who finished. Have a script write Amplitude's device ID into a hidden checkout field or cart data, never into cached page HTML, and store it on the order.

When the place transition fires, send the purchase with the stored device ID, plus the Drupal uid as user_id if the shopper is logged in or registers at checkout completion. Populate price and quantity per line from commerce_order_item, and productId from the variation SKU, so revenue and product analysis both work. Amplitude's revenue charts stay at zero when those fields are missing, even while event counts look right.

Drupal's configurable workflows decide when revenue happens. If your install uses a workflow with a validation step, sending at placement counts orders that staff later reject; pick the transition that matches what finance counts, and send a negative-revenue event when an order moves to canceled. On multilingual sites, the checkout under each language prefix must load the same Amplitude configuration, or one language's shoppers never get a device ID to store and their orders look like they came from nowhere.

Drupal Commerce → Amplitude · what breaks

Why this join usually fails — Drupal Commerce → Amplitude

  1. 01

    The user ID and device ID pair 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.

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

  3. 03

    Revenue events that carry no revenue

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  4. 04

    Nothing reconciles afterwards

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Drupal Commerce → Amplitude · the fix

What working looks like — Drupal Commerce → Amplitude

  • The user ID and device ID pair on every order

  • Conversions arriving in Amplitude

    The event lands on the user, joins their behavioural history, and becomes available for cohorts, funnels and retention.

  • Reconciled against the source

Drupal Commerce → Amplitude · architecture

How Drupal Commerce and Amplitude actually connect

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

    Amplitude needs a click to match

    Amplitude needs a device or user identifier, an event type and its properties. Revenue events need the price and quantity fields specifically, or the revenue reporting stays empty while events flow normally.

  3. 3

    The identifier is the bridge

    The user ID and device ID pair, captured at the visit and carried into the Drupal Commerce order.

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

    Deduplication at the destination

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

Drupal Commerce → Amplitude · normal or broken

Working vs. broken, side by side — Drupal Commerce → Amplitude

Normal, not a fault

  • The user ID and device ID pair present on the order

  • Sent from the Drupal Commerce order placement hook

  • Deduplicated correctly

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

  • Reconciles with the source

Actually broken

  • The user ID and device ID pair 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

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  • Nobody has reconciled it

Drupal Commerce → Amplitude · diagnose

Diagnostic order — Drupal Commerce → Amplitude

  1. 01

    Count orders carrying the user ID and device ID pair

  2. 02

    Follow one real conversion end to end

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

  4. 04

    Check a purchase event for the price and quantity fields specifically

    Not whether the event arrived — whether the revenue fields are populated, in the exact names Amplitude expects.

  5. 05

    Read the match rate, not the success message

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Drupal Commerce → Amplitude · prove

How it gets proven — Drupal Commerce → Amplitude

Source of truth

Drupal's commerce_order records in your own database, filtered to completed states.

  • The user ID and device ID pair confirmed present on a live order.
  • Revenue reconciled per transaction against your billing system, with identity merge behaviour verified across signup.
  • Order field data confirmed populated on an order placed through a fully warmed cache as an anonymous visitor.

Drupal Commerce → Amplitude · free audit

What we check in the free audit

  • Count orders carrying the user ID and device ID pair
  • Follow one real conversion end to end
  • List the order states in use and agree which count as revenue
  • Check a purchase event for the price and quantity fields specifically
  • Read the match rate, not the success message

Checked against

Drupal's commerce_order records in your own database, filtered to completed states.

Get my free conversion tracking audit

Free30 minutesNo obligation

Drupal Commerce → Amplitude · when not to buy

When you don't need this — Drupal Commerce → Amplitude

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the user ID and device ID pair.
  • If your Drupal site is content-only with commerce elsewhere, work at the commerce system instead — this is the wrong layer.
  • If nobody is building cohorts or retention analysis, this is a large amount of instrumentation for reporting a dashboard already gives you.

Drupal Commerce → Amplitude · what we deliver

What gets built — Drupal Commerce → Amplitude

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

    The Amplitude HTTP V2 API, posted server-side with the identity, event type and 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.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Drupal Commerce → Amplitude questions, answered

Check drupal.org for a maintained module on your Drupal version. For revenue, server-side events from an order event subscriber are more dependable than any browser-only module on a cached site.

Free · 30 min

Get Drupal Commerce and Amplitude joined properly

Free30 minutesNo obligation