Skip to main content
Magento → MatomoIntegration guide

Connecting Magento to Matomo

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

Magento orders in Matomo, sent server-side with the visitor ID

Send Magento orders to Matomo from the order placement observer through the HTTP Tracking API, with increment_id as order ID. Read the visitor ID from the _pk_id cookie on the place-order request, and save it to the quote at checkout as a fallback for server-callback payments. Map totals, tax, shipping, discount and line items, using base amounts for multi-currency stores.

Matomo's ecommerce tracking expects the order on the confirmation page, and that is where Magento is least dependable: customers who pay through a redirect method and close the tab never reach checkout/onepage/success. Send the order from the order placement observer through the HTTP Tracking API instead, with increment_id as the order ID so any browser hit for the same order is ignored rather than counted twice.

The join is the visitor ID. Matomo's tracker keeps a 16-character visitor ID in the _pk_id first-party cookie. The place-order request is never served from the full-page cache, so the observer can read that cookie from the request and pass it along. Some payment methods create the order from a server callback with no browser cookie at all, so save the visitor ID to the quote when the shopper enters checkout as a fallback. Without it, Matomo files the order under a new visit with no campaign.

Order values map cleanly: Matomo has fields for grand total, subtotal, tax, shipping and discount, and line items come from sales_order_item. Use base amounts if you sell in several currencies, since a Matomo site reports in one. Check whether your Matomo version can reverse an order after a credit memo; if not, report refunds from Magento. Community Matomo extensions for Magento exist, so check whether one is maintained for 2.4 and whether it tracks from the browser or the server.

Magento → Matomo · what breaks

Why this join usually fails — Magento → Matomo

  1. 01

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

    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.

Magento → Matomo · the fix

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

Magento → Matomo · architecture

How Magento and Matomo 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

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

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

Magento → Matomo · normal or broken

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

Normal, not a fault

  • The first-party visitor ID present on the order

  • Sent from the Magento order placement observer

  • 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

    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

    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

Magento → Matomo · diagnose

Diagnostic order — Magento → Matomo

  1. 01

    Count orders carrying the first-party visitor ID

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

Magento → Matomo · prove

How it gets proven — Magento → Matomo

Source of truth

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

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

Magento → 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
  • Place a test order as an anonymous visitor through cache
  • Check tracker reachability and database lag before debugging any tag
  • 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 → Matomo · when not to buy

When you don't need this — Magento → Matomo

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

Magento → Matomo · what we deliver

What gets built — Magento → Matomo

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

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

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

The order was sent without the visitor ID from the _pk_id cookie, so Matomo opened a new visit with no campaign. Read the cookie on the place-order request, or store it on the quote earlier in checkout.

Free · 30 min

Get Magento and Matomo joined properly

Free30 minutesNo obligation