Why Shopify and Server-Side Tracking Require Special Consideration
Shopify's architecture creates specific challenges for server-side tracking implementation. The platform controls the checkout pages (on standard plans), handles its own analytics through Shopify Analytics, and restricts where custom code can be placed. This means standard sGTM approaches require adaptation.
Option 1: Server-Side GTM with Shopify's Checkout Tracking
The most complete implementation involves:
- Deploying a sGTM server on your own subdomain (collect.yoursite.com)
- Routing Shopify storefront events (add to cart, view item, etc.) through sGTM from the storefront template
- Using Shopify's Order Webhook to trigger purchase events server-side on order confirmation
The webhook approach for purchases: When an order is confirmed, Shopify sends an HTTP POST to a URL you configure. This webhook fires for every order, regardless of whether the customer had JavaScript enabled or used an ad blocker. Your server receives the webhook, extracts the order data (value, items, currency, order ID), looks up the stored GCLID for that session (if you stored it in a Shopify note or metafield at checkout initiation), and sends the conversion event via GA4 Measurement Protocol or Google Ads offline conversion upload.
This is the most reliable purchase tracking available on Shopify — server-confirmed, ad-blocker immune, and based on actual payment data rather than browser-side optimism.
Option 2: Shopify Custom Pixels (Shopify's Built-In Server-Side Solution)
Shopify Plus and, increasingly, standard Shopify plans include Custom Pixels — a sandboxed JavaScript environment for tracking in checkout. Custom Pixels can send events to a custom endpoint (your sGTM server) with access to checkout event data including order total, items, and customer information (with appropriate consent).
Advantages of Custom Pixels:
- Access to checkout events on all pages (including restricted payment pages) — even on non-Plus plans
- Sandboxed for security — cannot access customer PII outside the Shopify consent framework
- Officially supported by Shopify — less likely to break with platform updates
What Custom Pixels can do: subscribe to checkout events (checkout_started, payment_info_submitted, checkout_completed) and forward them to your sGTM endpoint for processing and distribution to GA4, Google Ads, Meta CAPI, etc.
Option 3: Stape's Shopify Integration
Stape offers a pre-built Shopify integration for their managed sGTM hosting. It includes a Shopify App that handles:
- Automatic GCLID capture at session start
- Order webhook integration
- Purchase event forwarding to sGTM
- Cookie lifetime extension for returning visitors
This is the fastest path to server-side tracking on Shopify without custom development.
Storing the GCLID for Webhook Attribution
For server-side purchase attribution (connecting a Google Ads click to a confirmed order), you must capture and store the GCLID from the user's session. Methods on Shopify:
- URL parameter to cart attribute: on landing, read the gclid URL parameter with JavaScript and store it as a Shopify cart attribute. Cart attributes persist through checkout and appear in the order data — accessible via webhook.
- Cookie to order note: store the GCLID in a cookie, then use Shopify's checkout scripts (Plus only) to read the cookie and add it to the order note field.
- Custom app: a Shopify app that intercepts checkout events and associates GCLIDs with order IDs in a separate database.
Summary
Server-side tracking on Shopify is achievable through multiple paths. The most complete solution combines sGTM on a custom subdomain for storefront tracking, Shopify Order webhooks for server-confirmed purchase events, and GCLID storage via cart attributes for attribution. Shopify Custom Pixels provide a simpler, officially supported alternative for checkout event access.
See our Server-Side Tracking service for Shopify-specific implementation.
Need server-side tracking set up on your Shopify store? Contact Adslytics.
Need expert tracking setup?
Our Google Tag Manager experts have delivered 500+ tracking setups with a 98% success rate.
Get a Free Consultation →