Skip to main content
Drupal Commerce → MatomoIntegration guide

Connecting Drupal Commerce to Matomo

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. Matomo can be self-hosted with no third party in the chain, which makes it the one analytics destination where the data genuinely never leaves infrastructure you control. The join between them succeeds or fails on one thing: whether the first-party visitor ID reaches the Drupal Commerce order before the conversion happens, because Matomo can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Drupal Commerce to Matomo: server-side orders with the visitor ID

Store Matomo's visitor ID on the Drupal Commerce order during checkout, then post the ecommerce order through the HTTP Tracking API from the order placement hook, with the order number, items by variation SKU, revenue and the subtotal, tax and shipping split. Reconcile refunds against Drupal, and schedule archiving off-peak.

Drupal and Matomo are a common pairing, often on the same infrastructure, and the contributed Matomo module handles page tracking. The ecommerce order is where it goes wrong. A purchase tracked from the checkout complete page depends on that page rendering for every buyer, and on Drupal it may come from cache, be refreshed, or never be seen when an offsite gateway places the order through its notification. Matomo dedupes on order ID, so always send the Drupal order number.

The sturdier route is the HTTP Tracking API from the order placement hook. Read Matomo's visitor ID from its first-party cookie during checkout, store it on the order as a field, and post the ecommerce order with the order number, items by variation SKU, revenue, and the subtotal, tax and shipping split from Drupal's order adjustments, so Matomo's revenue columns line up with Drupal's.

If Matomo runs on the same server as Drupal, archiving reports competes with the store for the database; schedule it outside peak hours. Matomo's ecommerce reports will not net out refunds, so reconcile refunded and canceled orders against Drupal rather than expecting Matomo revenue to fall. If consent rules put Matomo in cookieless mode, orders still record but tie back to their visits less reliably.

Drupal Commerce → Matomo · what breaks

Why this join usually fails — Drupal Commerce → Matomo

  1. 01

    The first-party visitor 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.

  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

    Owning the pipeline means owning the outage

    The advantage is that nothing blocks it. The cost is that when the tracking database fills or falls behind on a weekend, the data is gone and no vendor is paging anyone. Hosted tools fail more visibly.

  4. 04

    Nothing reconciles afterwards

    Matomo exposes raw visit logs, so you can inspect the actual hit rather than an aggregate. Check the log, and check ingestion lag alongside it.

Drupal Commerce → Matomo · the fix

What working looks like — Drupal Commerce → Matomo

  • The first-party visitor ID on every order

  • Conversions arriving in Matomo

    The event lands in your own database and is queryable directly, including the raw log, which most analytics products do not expose.

  • Reconciled against the source

Drupal Commerce → Matomo · architecture

How Drupal Commerce and Matomo 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

    Matomo needs a click to match

    The site ID, the visitor identifier and the event or ecommerce order. Self-hosted instances additionally need the tracker endpoint reachable and the database keeping up, which hosted tools do not fail at.

  3. 3

    The identifier is the bridge

    The first-party visitor ID, 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

    Matomo deduplicates ecommerce orders on order ID. Without one, a refreshed confirmation page records a second order.

Drupal Commerce → Matomo · normal or broken

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

Normal, not a fault

  • The first-party visitor ID present on the order

  • Sent from the Drupal Commerce order placement hook

  • Deduplicated correctly

    Matomo deduplicates ecommerce orders on order ID. Without one, a refreshed confirmation page records a second order.

  • Reconciles with the source

Actually broken

  • The first-party visitor 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

    The advantage is that nothing blocks it. The cost is that when the tracking database fills or falls behind on a weekend, the data is gone and no vendor is paging anyone. Hosted tools fail more visibly.

  • Nobody has reconciled it

Drupal Commerce → Matomo · diagnose

Diagnostic order — Drupal Commerce → Matomo

  1. 01

    Count orders carrying the first-party visitor ID

  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 tracker reachability and database lag before debugging any tag

    On self-hosted analytics the answer is infrastructure more often than instrumentation.

  5. 05

    Read the match rate, not the success message

    Matomo exposes raw visit logs, so you can inspect the actual hit rather than an aggregate. Check the log, and check ingestion lag alongside it.

Drupal Commerce → Matomo · prove

How it gets proven — Drupal Commerce → Matomo

Source of truth

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

  • The first-party visitor ID confirmed present on a live order.
  • Orders reconciled against the Matomo ecommerce log with order-ID deduplication verified.
  • Order field data confirmed populated on an order placed through a fully warmed cache as an anonymous visitor.

Drupal Commerce → Matomo · free audit

What we check in the free audit

  • Count orders carrying the first-party visitor ID
  • Follow one real conversion end to end
  • List the order states in use and agree which count as revenue
  • Check tracker reachability and database lag before debugging any tag
  • 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 → Matomo · when not to buy

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

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the first-party visitor ID.
  • If your Drupal site is content-only with commerce elsewhere, work at the commerce system instead — this is the wrong layer.
  • If you have no privacy or ownership requirement and no team to run it, a hosted product removes the only real cost of this one.

Drupal Commerce → Matomo · what we deliver

What gets built — Drupal Commerce → Matomo

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

    The Matomo HTTP Tracking API, posted server-side from your order system.

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

Page tracking, yes. Purchases from the confirmation page are fragile on Drupal; sending the order server-side from the placement hook with the stored visitor ID is more reliable.

Free · 30 min

Get Drupal Commerce and Matomo joined properly

Free30 minutesNo obligation