Server-side tracking for a Shopify store

An external conversion tool was replaced by a Shopify custom pixel and server-side GTM, with direct connections to GA4, Google Ads, and Meta.

Context
Ecommerce, Shopify
Focus
Architecture, migration, operations
Period
2023–2026
Stack
  • Server-side tagging
  • Shopify Web Pixels API
  • GA4
  • GTM web & server
  • Google Ads
  • Meta CAPI
  • Consent Mode v2

Background

The store measured its campaigns with an external conversion tool. From the outside, it was hard to verify how the tool collected data and attributed purchases. It was to be replaced by a dedicated setup without disrupting the running campaigns.

Implementation

The new tracking first ran in parallel with the old tool. This made it possible to compare both data sets with the store’s orders before switching over.

The ecommerce events come from a custom pixel built on the Shopify Web Pixels API. The pixel runs in a sandbox inside an iframe. There, the page URL and page title do not match the actual store page, so both are passed explicitly. Because GTM can only be debugged to a limited extent inside the sandbox, a separate debugging workflow in the browser covers it.

The events go to a server-side GTM container on a subdomain of the store. From there, GA4, Google Ads, and the Meta Conversions API are served. For Enhanced Conversions, a custom, tested server template normalizes and hashes the customer data. The store’s consent app was updated to Consent Mode v2, and the consent state is sent to the server with every event.

Result

Campaign measurement now runs entirely on the new setup. The numbers match the store’s orders and an independent comparison measurement. Without the old tool’s attribution, the ROAS of individual campaigns looked considerably different. This allowed the budget allocation to be reassessed.