Connecting Craft CMS to Matomo
Craft is a developer-oriented CMS, usually built bespoke by an agency, which means the implementation is whatever that agency decided and nothing is standard. 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 Craft 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
Craft Commerce to Matomo: order ID and the visitor cookie
Read the Matomo visitor ID from the _pk_id cookie during checkout and store it on the Craft order. Post the order from the order-complete listener to the HTTP Tracking API with that ID, the order reference as order ID, SKU line items and revenue split into subtotal, tax, shipping and discount. Handle refunds separately.
Craft and Matomo meet often on privacy-sensitive builds, where the agency hosts Matomo alongside the site. The Matomo JavaScript tracker in the layout template survives static caching, since it runs in the browser. The ecommerce order is where it slips: tracking it from a Twig confirmation template ties the order to whether that page rendered uncached and whether the tab stayed open long enough.
Track the order server-side instead. Read the Matomo visitor ID from the _pk_id cookie during checkout, store it in an order custom field, and post the order from the order-complete listener to the HTTP Tracking API with that visitor ID, the order reference as the order ID, line items with SKUs, and revenue split into subtotal, tax, shipping and discount the way Matomo's ecommerce reports expect. The order ID makes Matomo ignore a second post of the same order.
Matomo's ecommerce tracking has no native refund in most versions, so refunds recorded against the Craft order need handling as a separate custom event or in your own reconciliation; check what your version supports. And if Matomo runs on the same server as Craft, a busy sale slows both: a full database or archiving that falls behind shows up as missing orders days later, not as an error during checkout.
Craft → Matomo · what breaks
Why this join usually fails — Craft → Matomo
- 01
The first-party visitor ID never reaches Craft
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
- 02
Every install is bespoke
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
- 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.
- 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.
Craft → Matomo · the fix
What working looks like — Craft → 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
Craft CMS's own records are the reference, not either dashboard.
Craft → Matomo · architecture
How Craft and Matomo actually connect
- 1
Craft CMS holds the truth
Craft installs are bespoke by nature. Establish how this particular build models a completed order before assuming anything transfers from another Craft site.
- 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
The identifier is the bridge
The first-party visitor ID, captured at the visit and carried into the Craft Commerce order.
- 4
The event source decides reliability
Fire from the event listener in PHP rather than a Twig template, which may be cached.
- 5
Deduplication at the destination
Matomo deduplicates ecommerce orders on order ID. Without one, a refreshed confirmation page records a second order.
Craft → Matomo · normal or broken
Working vs. broken, side by side — Craft → Matomo
Normal, not a fault
The first-party visitor ID present on the order
Visible on the record itself in Craft CMS, not merely captured somewhere on the site.
Sent from the Craft Commerce order-complete event
Deduplicated correctly
Matomo deduplicates ecommerce orders on order ID. Without one, a refreshed confirmation page records a second order.
Reconciles with the source
Matomo's count and Craft CMS's records agree within a few percent over a closed window.
Actually broken
The first-party visitor ID missing on most records
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
Sent from the browser
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
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
The dashboard shows a number and no one has compared it to Craft CMS.
Craft → Matomo · diagnose
Diagnostic order — Craft → Matomo
- 01
Count orders carrying the first-party visitor ID
- 02
Follow one real conversion end to end
- 03
Read how this specific build handles order completion
Assumptions carried from another Craft project are the main source of wasted time here.
- 04
Check tracker reachability and database lag before debugging any tag
On self-hosted analytics the answer is infrastructure more often than instrumentation.
- 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.
Craft → Matomo · prove
How it gets proven — Craft → Matomo
Against Craft CMS's own records, not against either platform's dashboard.
Source of truth
Craft Commerce's order records in your own database, filtered to completed.
- The first-party visitor ID confirmed present on a live order.
- Orders reconciled against the Matomo ecommerce log with order-ID deduplication verified.
- Order custom field confirmed populated on an order placed as an anonymous visitor through cache.
Craft → 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
- Read how this specific build handles order completion
- Check tracker reachability and database lag before debugging any tag
- Read the match rate, not the success message
Checked against
Craft Commerce's order records in your own database, filtered to completed.
Free30 minutesNo obligation
Craft → Matomo · when not to buy
When you don't need this — Craft → Matomo
- If Matomo already reports conversions that reconcile against Craft CMS's records within a few percent, this join is working and there is nothing to buy.
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the first-party visitor ID.
- If the original agency is still engaged, the fastest path is usually specifying the field and having them add the hook.
- 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.
Craft → Matomo · what we deliver
What gets built — Craft → Matomo
Identifier capture into Craft
Capture the identifier and store it as a custom field on the order through a Craft event listener, server-side.
Event source: the Craft Commerce order-complete event
Fire from the event listener in PHP rather than a Twig template, which may be cached.
Dispatch to Matomo
The Matomo HTTP Tracking API, posted server-side from your order system.
Reversals where they exist
Refunds and cancelled orders are recorded against the order.
Written guarantee
95%+ tracking accuracy
Measured against Craft Commerce's order records in your own database, filtered to completed.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Craft → Matomo questions, answered
Store the Matomo visitor ID on the order at checkout and post the order server-side from the order-complete event, with the order reference as the order ID.
Not as a native ecommerce refund in most versions; check yours. Track refunds as a separate event or reconcile them against Craft's order records.
Almost always because the first-party visitor ID never reached the Craft Commerce order. Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look. Measure coverage before debugging the dispatch.
Matomo sets its own first-party cookie and, when self-hosted on your domain, is not a third-party request at all. That means ad blockers and browser tracking-prevention affect it far less than a hosted analytics tag — one of the few genuine measurement advantages available under current privacy conditions.
The Craft Commerce order-complete event. Fire from the event listener in PHP rather than a Twig template, which may be cached.
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.
More on Craft → Matomo
- Craft → Google AdsConnecting Craft CMS to Google Ads
- Craft → MetaConnecting Craft CMS to Meta Conversions API
- Craft → GA4Connecting Craft CMS to GA4
RELATED GUIDES
Where Craft → Matomo fits in the rest of your tracking
- Concrete CMS → MatomoConnecting Concrete CMS to Matomo
- Sanity → MatomoConnecting Sanity to Matomo
- Sitecore → MatomoConnecting Sitecore to Matomo
- Craft → Adobe AnalyticsConnecting Craft CMS to Adobe Analytics
- Craft → AmplitudeConnecting Craft CMS to Amplitude
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Statamic → MatomoConnecting Statamic to Matomo
- Drupal Commerce → MatomoConnecting Drupal Commerce to Matomo
Free · 30 min
Get Craft and Matomo joined properly
Free30 minutesNo obligation
