What This Series Covers
If you run a headless commerce site, you may have noticed that the number of purchases recorded in GA4 is clearly lower than the orders in your back office. Product views and add-to-cart events come through fine — only purchases fail to line up. You want to judge whether your ad spend is paying off, but the revenue side of the equation is the part you can't trust.
Most of the time the cause sits at one specific moment: the jump from cart to checkout. In a headless setup, the front end that shows products and the checkout that handles payment run as separate systems, so the tracking thread snaps right at that seam. This is less a misconfiguration than a natural consequence of the architecture.
This series explains how to record purchase conversions (here, "an order whose payment has been confirmed") reliably, broken into three steps.
Three Layers That Keep Purchases from Slipping Through
The steps build on each other. Skip any one of them and the numbers stop matching.
- Identify exactly where data is lost
- Hand the user's identifying information to the order before the checkout redirect
- Use the payment-complete notification to send the purchase to GA4 from the server
In one sentence: park the information that only exists inside the browser onto the order before checkout, then send it again from the server once payment is done.
Read the Details
Each step has its own article. Reading them in order takes you from the reasoning behind the design to how the pieces actually fit together.
Why Conversion Tracking Breaks in Headless Setups
Pinpoints the boundaries where tracking snaps in headless commerce and what is lost at each one.
Bridging Cookies Before the Checkout Handoff
How to carry identifiers into order data, plus fail-open behavior and allowlist controls.
Sending purchase from the orders/paid Webhook via GA4 Measurement Protocol
Server-side purchase delivery after payment, deduplication, and what to monitor.
Technologies Used
- Next.js (the foundation for building the storefront)
- Shopify Storefront API / Admin API (exchanging product and order data)
- Shopify Webhook (automatic notifications for events such as completed payments)
- GA4 Measurement Protocol (the endpoint for sending data to GA4 directly from a server)
Operational Rules to Agree On First
The operating rules matter as much as the technical build. Settling these four points with everyone involved before implementation saves a lot of rework later.
- Never publish the real environment variable names or key names in use
- Always put authentication in front of administrative APIs
- If the handoff step fails, never block the purchase path
- Keep personal data and credentials out of logs
The third point is the one worth repeating: halting revenue for the sake of measurement gets the priorities backwards. Tracking is a support function, and it never outranks the buying experience.