Magento tracking

Magento Conversion Tracking: GA4, Meta CAPI & Server-Side GTM

This is for Magento Open Source and Adobe Commerce stores whose ad platforms don't match the orders in the admin. Magento gives you full control, but full page cache, a JavaScript-driven checkout, theme differences and extensions all affect what tracking sees. I build a dataLayer that works with caching, a GTM setup that reads it, and a server-side purchase feed from order data.

Magento · Ecommerce
  • GA4 ecommerce dataLayer that stays correct with full page cache on
  • Checkout steps tracked in the JavaScript checkout
  • Server-side purchases sent from Magento order events
  • Works with Luma, Hyvä and headless storefronts
Quick answer

Proper Magento tracking means a GA4 ecommerce dataLayer from a maintained extension or a custom module, with customer and cart data loaded outside the cached page. GTM reads it for browser tags, the purchase fires once on the success page, and a server-side purchase from order events goes to Meta CAPI and other platforms with a shared event ID.

Tracking flow

How tracking works on Magento

The events I set up on Magento, and where each one is sent.

Why it breaks

Why Magento tracking goes wrong

Full page cache serves stale data

With Varnish or the built-in full page cache, the same HTML is served to many visitors. If cart or customer details are printed into the page, the dataLayer can show someone else's data or nothing at all.

No complete GA4 dataLayer out of the box

Magento Open Source ships only basic Google integrations. Adobe Commerce includes a Tag Manager module, but most stores still need an extension or custom module for a full GA4 ecommerce dataLayer.

The checkout is a JavaScript app

Shipping and payment steps change without a full page load. Page-view triggers miss them, so begin_checkout, add_shipping_info and add_payment_info need events tied to the checkout's own steps.

Themes break older extensions

Tracking extensions written for the Luma theme often don't work on Hyvä or a headless frontend, because the JavaScript they rely on isn't there. Add-to-cart and mini-cart events are usually the first to fail.

Redirect payments skip the success page

Customers who pay through an external payment page don't always return to the success page, so the browser purchase never fires even though the order is in Magento.

What I set up

My Magento tracking setup

dataLayer & GTM

  • GA4 ecommerce dataLayer via a maintained extension or a custom module
  • Cart and customer data loaded through private content, not cached HTML
  • Product IDs aligned with your Merchant Center feed
  • Checkout step events from the JavaScript checkout
  • Clean-up of old extensions and hard-coded tags

Purchase & ads

  • purchase on the success page with order ID, value, tax, shipping and items
  • Purchase guarded so it fires once per order
  • Google Ads purchase conversion with enhanced conversions
  • Meta Pixel and TikTok purchase with shared event IDs

Server-side

  • Server-side GTM on Stape or Google Cloud with a tracking subdomain
  • Purchase sent from Magento order events, queued so checkout isn't slowed
  • Meta Conversions API with hashed customer data
  • GA4 Measurement Protocol or server GA4 for missed purchases
  • Refund and cancellation handling where your reporting needs it

Testing & handover

  • Tests with full page cache enabled, not disabled
  • Test orders through each payment method
  • Multi-store and multi-currency checks
  • Revenue reconciliation against Magento orders
  • Written event map for your developers
Event map

Events I track on Magento

EventWhen it firesSent to
view_item_listCategory or search results page loadsGA4
view_item / ViewContentProduct page loadsGA4, Meta Pixel + CAPI, TikTok
add_to_cart / AddToCartProduct added, including AJAX add-to-cartGA4, Meta Pixel + CAPI, TikTok
begin_checkout / InitiateCheckoutCheckout opensGA4, Meta Pixel + CAPI, TikTok
add_shipping_infoShipping step completed in checkoutGA4
add_payment_infoPayment method selectedGA4
purchase / PurchaseCheckout success page (first load only)GA4, Google Ads, Meta Pixel, TikTok
purchase (server)Order placed or invoiced in Magento, sent to server-side GTMMeta CAPI, GA4, TikTok Events API
Process

How the setup works

  1. 01

    Audit

    I review installed extensions, theme, caching setup and payment methods, and compare platform conversions with Magento orders.

  2. 02

    Choose the dataLayer approach

    Depending on your theme and team, I recommend a maintained extension or a small custom module, and agree it with your developers.

  3. 03

    Build

    The dataLayer, GTM container, checkout events and server-side purchase feed are built and deployed to staging first.

  4. 04

    Test with caching on

    I test with full page cache active, through each payment method and store view, and confirm each order is counted once.

  5. 05

    Release and monitor

    After release I compare platform data with Magento for two weeks, then hand over the event map and notes for future upgrades.

Making the dataLayer work with full page cache

Magento caches whole pages so they load fast. That's good for speed and bad for tracking code that prints the cart or logged-in customer into the page, because the cached copy is shared. The fix is to keep page-level data, such as the product on a product page, in the cached HTML, and load anything personal through Magento's private content (customer data sections) or a small AJAX call after the page loads.

I test this with caching switched on. Turning the cache off during testing hides exactly the problems that break tracking in production.

Server-side purchases from Magento orders

The success page is the only place the browser can report a purchase, and not every customer reaches it. A server-side purchase, sent when the order is placed or invoiced, fills that gap. In Magento this is usually an observer or a queue consumer that sends order data to server-side GTM without slowing checkout.

The server event carries the same event ID the browser would use, so Meta and other platforms keep one copy when both arrive. It also includes hashed email and phone, which improves match quality for Meta CAPI and Google Ads enhanced conversions.

FAQ

Magento tracking FAQ

What's the best way to add GA4 to Magento?

Use GTM with a GA4 ecommerce dataLayer from a maintained extension or a custom module, rather than hard-coded tags. Adobe Commerce has a built-in Tag Manager module, but check that its dataLayer covers the GA4 events you need.

Does full page cache break Magento tracking?

It can, if cart or customer data is printed into cached pages. Personal data should load through customer data sections or after the page loads. I always test tracking with the cache enabled.

Does this work with the Hyvä theme?

Yes, but many Luma-based tracking extensions don't. I check that the extension supports Hyvä, or build the events for Hyvä's JavaScript, especially add-to-cart and the mini-cart.

How do I send Meta Conversions API events from Magento?

Either through an extension that supports CAPI, or by sending order events to server-side GTM, which forwards them to Meta. I prefer server-side GTM because the same feed can also go to GA4, Google Ads and TikTok.

Can you work with my Magento developers or agency?

Yes. I usually write the dataLayer spec and GTM setup, and your developers deploy any module changes. I then test on staging and production before sign-off.

Guides

Read next

Want your Magento tracking fixed?

Get a free audit of your tracking and ad account. Usually replies within 1–2 hours.