Learn / The Complete Guide to Setting Up First-Party Data Tracking for Shopify Using Server-Side GTM + Stape

The Complete Guide to Setting Up First-Party Data Tracking for Shopify Using Server-Side GTM + Stape

Picture of Mark Kovic

Would you like TDS to support you in your online marketing efforts? Click Here

At TDS, we have spent the last few years refining what we consider the most robust, cost effective, and standardised solution for First Party Data (FPD) systems. We want data systems for Shopify stores to be compliant, optimal for powering analytics and marketing platforms, and reliable long term in a manner that minimises upkeep and maintenance. This guide is based on our experience in the field, and among many different options for setting up FPD systems, we advise the use of the following platforms;

  • Google Tag Manager (Client + Server)
  • GA4 as the source of truth
  • Stape for server-side hosting
  • Server-side Google Ads + Meta CAPI

Summary (Click to Jump to Any Section)

1. Why Does First-Party Data Matter for Shopify

Shopify stores have been disproportionately affected by modern privacy changes that affect how they function. While Shopify stores are directly affected, surrounding tools like online ads platforms, AI systems and analytics typically either stop functioning, or do not work optimally. Browser blocking, iOS restrictions, and disappearing cookies cause issues when it comes to powering these systems with correct, and consented data. Understanding the journey of a user from being stranger, to being a purchaser often involves many touchpoints where a user interacts with the store on multiple occasions from different sources. The ability to understand this user journey from an analytics and marketing perspective is crucial, and much of it cannot work without a first-party-data infrastructure.

Issues occur such as;

  • Missing events like ‘purchases’
  • Inflated or mismatched reporting in analytics tools, which can cause incorrect decision-making
  • Unstable or innacurate in-platform ROAS
  • Higher CPAs than are possible with 1st party systems
  • Unreliable or ineffective systems optimisation, especially with advertising systems

How do we solve this using a First-Party-Data (FPD) infrastructure?

  • Tracking systems run on your own domain, so data is handled at your own server, meaning no reliance on 3rd party systems.
  • Click IDs (gclid, fbclid, ttclid) are preserved due to the ability to utilise first-party tracking mechanisms
  • Consent choices are respected and consent systems instruct tracking systems what they can or can’t measure and send
  • Data is enriched and processed server-side
  • All platforms receive clean, consistent conversion events from one source of truth, leading to better data-driven-attribution
  • Businesses analytics tools and marketing systems can function optimally

2. What Do You Need Before Starting a First Party Data Setup for Shopify?

The most time consuming element of an FPD setup, is often access management. This is where you need to make sure you can login and control the various tools and assets. If you don’t have access to the below systems, you may simply need to create one, nevertheless – before you start you should check the following requirements;

Requirements

  • Shopify Admin access
  • Google Tag Manager account
  • Google Analytics 4 property
  • Account setup with a verified consent management platform
  • Stape.io account
  • Access to your domain DNS
  • Google Ads admin rights
  • Meta Business Manager & Pixel access
  • Admin rights to any other ads platforms you may want to setup (TikTok Business Manager, Snapchat ads, LinkedIn ads, ChatGPT ads etc)
  • Access to a verified consent management platform – we tend to use CookieYes

3. How to Create Your Client-Side GTM Container

Creating your client-side Google Tag Manager (GTM) container is the first step in building your first-party data infrastructure. This container acts as the main control center running on your website, capturing key user actions like page views, add-to-carts, and purchases. It also handles consent signals from your cookie banner and feeds all of this information into the dataLayer (the structured event stream of what happened and when). By starting with a dedicated GTM container, you ensure every event is collected consistently, cleanly, and in a format you can standardise and control before it moves anywhere else in your tracking pipeline.

A client-side GTM Container;

  • Measures user actions that users take on your shopify store
  • Considers the consent choices from your Consent Management Platform
  • Triggers GA4 events
  • Sends events to your server container

How to Create It

  1. Visit tagmanager.google.com
  2. Click Create Account
  3. Give it a name (e.g. StoreName)
  4. Select Web as the container type
  5. Finish setup – when you finish your client side tag manager setup, you will see a GTM code is generated. You can ignore this code for now.

4. Configure GA4 Inside GTM

GA4 acts as your “translator,” taking all the events detected by GTM, like page views, add-to-carts, form submissions, and purchases. Then it standardises them into one consistent format. This matters because different apps, themes, and parts of Shopify often produce events in different shapes. By routing everything through GTM first and then into GA4, you create a clean, unified source of truth that every platform can rely on. This consistency is what allows your server-side container, your ads platforms, and your CRM to all receive the same event data, formatted the same way, with the same values. In short, configuring GA4 inside GTM ensures accuracy, removes fragmentation, and lays the foundation for trustworthy analytics and effective optimisation across your marketing stack. It also allows the use of Data Driven Attribution.

Add GA4 Configuration Tag

  1. GTM → Tags → New
  2. Choose GA4 Configuration
  3. Enter Measurement ID
  4. Trigger on All Pages

Add GA4 Event Tags

  • view_item
  • add_to_cart
  • begin_checkout
  • add_payment_info
  • purchase

  • value
  • currency
  • items[]

5. Create Your Server-Side GTM Container

The Server container is vital for;

  • Hashing of user data
  • Deduping browser/server events
  • Filtering bots
  • Formatting events correctly
  • Enforcing consent rules

How to Create It

  1. In GTM → Create Container
  2. Name it YourStore – Server
  3. Choose Server as the container type

6. Host Server-Side GTM on Your Domain via Stape

Hosting a server container in Stape is the most straightforward and cost effective option on the market in our experience. You start by creating a new Server-Side GTM container inside your Google Tag Manager account as in step 5. Once it’s created, Login to your Stape account, and it will give you a guided setup: choose “Create Container,” and configure it with your GTM Server Container. Stape automatically provisions the hosting for you by spinning up a server instance and generating the required endpoint URL. That URL becomes the server container’s address (e.g., gtm.yoursite.com once you add your custom domain).

Next, you connect your own subdomain to Stape so your server container runs on your brand’s domain instead of a generic one. In your DNS settings, you create a CNAME record pointing your subdomain (like data.yoursite.com) to the Stape-provided target. Once it propagates, Stape verifies the domain, and your server container is officially live. This means it’s ready to receive data from your client-side GTM setup and send clean, server-side events to platforms like Meta, Google Ads, and GA4. This helps with;

  • First-party cookie capability
  • Higher platform trust
  • Improved match quality
  • Better compliance

Setup steps

  1. Log into Stape.io
  2. Click Create Container → Server-Side GTM
  3. Enter subdomain (e.g. data.yourstore.com)
  4. Add DNS records Stape provides
  5. Allow DNS to propagate
  6. Connect Server GTM Container ID

This is how we make sure data captured by the client-side GTM, flows to the server container.

How to Connect Them

  1. In Client GTM → Admin → Container Settings
  2. Add your server URL:
    https://data.yourstore.com
  3. Enable Send to server container on GA4 tags
  4. Preview and publish

8. Configure GA4 Server-Side

Making sure that Google analytics reads from server-side data means;

  • Consistent attribution
  • Higher data accuracy
  • Protection from browser blocking

How to Configure It

  1. In Server GTM → Clients → Add GA4 Client
  2. Add a GA4 Tag (Server)
  3. Enter your Measurement ID
  4. Forward all event parameters

9. Install GTM on Shopify

While there are many different ways to achieve the goal of an FPD infrastructure, if you’re using Shopify, we suggest using Stape to handle the GTM installation, as opposed to using the base code in the head section.

The reason is simple: Shopify’s theme files are dynamic, often overwritten during updates, and behave differently across templates like product, cart, and checkout. A manual installation can easily lead to GTM loading inconsistently, firing on the wrong pages, or missing critical events on checkout and thank-you pages.

Stape’s Shopify app solves this in a standardised manner. It injects the GTM client script in a stable, update-considerate way across every page of your store – product, collection, cart, checkout, and order confirmation. It also gives you full control over directing that traffic to your server-side endpoint, which you can’t achieve with a basic theme edit. This not only reduces technical overhead but also prevents tracking gaps, duplicate events, or script conflicts caused by third-party apps. In short, Stape (in our opinion) provides the most reliable, low-maintenance foundation for accurate first-party tracking on Shopify.

  • Go to the Shopify App Store and search for “Stape Conversion Tracking”
  • Click Install App and approve the permissions
  • Open the Stape app inside Shopify
  • Enter your Client-Side GTM Container ID (GTM-XXXXXXX)
  • Add in Server-Side Container URL
  • Enable any extra features such as Custom Loader and Cookie Keeper
  • Configure the ecommerce DataLayer to add standard events to your shop
  • Set up your custom checkout pixel to track checkout events
  • Save your settings; Stape will automatically inject GTM into:

    • product pages
    • collection pages
    • cart
    • checkout (Shopify Plus)
    • thank-you page
  • Publish both the Client and Server GTM containers once testing is successful
How does server side tracking work with shopify?

10. Set Up Google Ads Server-Side (CAPI)

Setting up Google Ads server-side is surprisingly straightforward once GA4 is in place. Because GA4 already receives all your key events in a clean, standardised format, you can use it to pass those same events directly to Google Ads through a secure server-side connection. Think of GA4 as the bridge: GTM sends the event, GA4 records it, and your server forwards the conversion to Google Ads with far greater accuracy than the old browser pixel ever could. This means Google Ads gets reliable, consent-compliant conversion data even when cookies are blocked, helping your campaigns learn faster, optimise better, and spend more efficiently. It helps for;

  • bidding
  • attribution accuracy
  • conversion value tracking

How to Configure It

Simply head to the data-manager in Google ads on the left side tab when you’re in google ads. In the Data manager, you can simply connect the GA4 property that you used when setting up GTM. Note, that once this is connected, you may want to import conversions into Google ads, from GA4 depending on what goals you want to aim your campaigns towards.

11. Set Up Meta Server-Side CAPI

How to Configure It

  1. In Server GTM → Tags → New → Meta CAPI
  2. Add:

    • Pixel ID
    • Access Token
  3. Map:

    • event_name
    • event_time
    • value
    • currency
    • contents[]
    • content_ids
    • fbp / fbc
    • email / phone (hashed)
  4. Enable deduplication
  5. Test in Meta Events Manager → Test Events

12. Test, Debug & Validate

Most ads and analytics platforms have an area where you can test which events arrive when you are interacting with a web-asset. Take your time to check each platform that you rely on, whether the ‘debug mode’ in GA4, the ‘test events’ section in Meta, or other various testing areas – it’s vital to make sure that your server-side GTM is sending correct data to your platforms, and you can see it working in real-time.

Test User Actions

  • view product
  • add to cart
  • initiate checkout
  • purchase

Validate in GA4

  • DebugView
  • Realtime reporting

Validate in Meta

  • Test Events
  • Match quality score

Validate in Google Ads

  • Conversion diagnostics
  • Enhanced conversions status

13. Final Checklist

  • GA4 shows server-side purchase events
  • Meta shows deduped browser + server events
  • Google Ads receives server conversions
  • Click IDs persist through checkout
  • Consent mode is functioning
  • Shopify revenue matches GA4 revenue
  • No duplicated conversions
  • Ad platform attribution stabilises

Basic setup steps like creating GTM containers and linking them can be done with clear instructions. However, installing and configuring server-side GTM, hosting it on your own domain via Stape, and ensuring correct data flow into platforms like GA4, Meta CAPI, and Google Ads usually benefits from some technical knowledge, especially when setting up DNS records and validating events. Many users choose a hosted solution or professional support to simplify this process.

Once installed, you should test and validate your tracking in all major platforms:

  • GA4 DebugView / Realtime: see server-side purchase and event data flowing.
  • Meta Events Manager (Test Events): confirm events arrive and check event match quality.
  • Google Ads Diagnostics: ensure server-side conversions are received.
    Also verify that Shopify revenue matches GA4, click IDs persist through checkout, and there are no duplicated conversions across platforms.

No – when implemented correctly, server-side tracking can actually improve site performance. Because many tracking requests are moved off the browser and handled on the server, there are fewer scripts running on the storefront. This reduces page load times, improves Core Web Vitals, and creates a cleaner checkout experience, while still sending accurate data to platforms like GA4, Meta, and Google Ads.

Would you like our team to help you run your online marketing? We'll audit your store or website for free.

Get the book