Shopify powers millions of eCommerce stores worldwide. Many store owners rely heavily on paid advertising platforms like Google Ads and Meta Ads to drive traffic and generate sales.
However, the success of paid advertising depends heavily on accurate conversion tracking. When conversions are not recorded correctly, advertising platforms receive incomplete or inconsistent data. This can negatively impact Smart Bidding, attribution models, and overall campaign performance.
Modern browser restrictions, privacy updates, and ad blockers have made traditional browser-based tracking less reliable. That is why many Shopify stores are moving toward server-side tracking.
In this guide, we will walk through how to build a reliable server-side tracking setup for Shopify using:
- Google Tag Manager (Web + Server containers)
- Google Analytics 4 (GA4)
- Stape.io server hosting
- Shopify Webhooks
- Stape Store for attribution recovery
By the end of this tutorial, you will understand how to create a system that captures conversions even when browser tracking fails.
Why Server-Side Tracking Is Important
Before diving into the setup, it’s important to understand why server-side tracking has become essential for modern eCommerce tracking.
Several major changes have made browser-based tracking unreliable.
1. Third-Party Cookie Restrictions
Most modern browsers restrict or completely block third-party cookies. Chrome is also gradually moving toward eliminating them.
Traditional marketing tools relied heavily on these cookies to store identifiers and attribute conversions to ad clicks.
Server-side tracking helps solve this problem because you can:
- Use first-party cookies
- Set cookies from your own domain
- Maintain stable attribution data
Another issue occurs with browsers like Safari. Even first-party cookies may be restricted if they are set from third-party IP addresses.
Using Server GTM with a custom tracking domain helps reduce this issue by ensuring cookies originate from your own domain.
2. Ad Blockers
Ad blockers have become increasingly common. Many users run extensions that block scripts associated with advertising or analytics.
These blockers can prevent:
- Google Tag Manager from loading
- Google Analytics from sending events
- Google Ads or Meta scripts from firing
With server-side tracking hosted on a custom domain, tracking scripts appear to come from your own site rather than third-party domains. This makes them less likely to be blocked.
3. Browser Script Blocking
Browsers like Safari and Brave go even further by blocking some tracking scripts entirely.
If the Web GTM container fails to load, every tag inside that container also fails.
When you move tracking logic to a Server GTM container, data can still be processed server-side even if some client-side scripts are restricted.
Shopify Cookie Limitations (Important)
Shopify introduces an additional challenge.
In certain configurations — particularly with Checkout Extensibility — cookie headers may not be forwarded in requests.
This creates a tracking problem because important identifiers may disappear before reaching your server container.
Examples include:
_gcl_aw(Google Ads click ID)_ga(Google Analytics client ID)_fbpand_fbc(Meta identifiers)
Without these values, advertising platforms cannot properly attribute conversions.
To solve this, we capture and store cookie values earlier in the customer journey, before Shopify removes them.
Overview of the Tracking Architecture
A reliable Shopify tracking setup usually follows this flow:
- User visits the website
- Cookies and identifiers are captured in the browser
- Important values are stored in Stape Store
- Shopify later sends a purchase webhook
- The server container retrieves stored attribution data
- The purchase event is enriched and sent to ad platforms
This allows the server container to reconstruct attribution data even when cookies are missing from the webhook.
Step 1: Create a Server-Side Google Tag Manager Container
Start by creating a Server GTM container.
Inside Google Tag Manager:
- Create a Server container
- Deploy it using Stape.io or another hosting provider
- Assign a custom subdomain
Example:
tracking.yourstore.com
Using a custom domain ensures that your server container can properly set and read first-party cookies.
Step 2: Install the Stape Conversion Tracking App in Shopify
Next, install the Stape Conversion Tracking App from the Shopify App Store.
Once installed, go to:
Sales Channels → Online Store → Customize → App Embeds
Enable the Stape Conversion Tracking app.
This app helps automate several steps:
- Installs the GTM Web container snippet
- Generates eCommerce Data Layer events
- Routes events to your Server GTM container
Step 3: Configure App Settings
Inside the Stape app configuration panel, configure the following options.
Add Your GTM Web Container ID
Enter the Web GTM container ID used on your storefront.
Example:
GTM-XXXXXXX
Add Your Custom Tracking Domain
Use the same custom subdomain you configured for your server container.
Example:
tracking.yourstore.com
This ensures cookies are treated as first-party cookies.
Enable Custom Loader (Recommended)
Custom Loader allows your website to load the GTM script from your own domain instead of googletagmanager.com.
Benefits include:
- Reduced risk of ad blocker interference
- Improved script reliability
Enable Cookie Keeper (Optional but Helpful)
Cookie Keeper extends cookie lifetimes and helps reduce the impact of Safari’s Intelligent Tracking Prevention (ITP).
Make sure it is enabled inside your Stape container before activating it in the app.
Step 4: Enable eCommerce Data Layer Events
Inside the Stape app:
Go to the Data Layer section and enable:
Add eCommerce Data Layer events
This will generate events such as:
view_itemadd_to_cartbegin_checkoutpurchase
Important note:
These events only push data into the Data Layer. They do not automatically send data to advertising platforms.
Step 5: Add the Custom Pixel Snippet
Shopify requires adding a Custom Pixel snippet under Customer Events.
This snippet triggers Data Layer events for Shopify actions such as:
- checkout started
- payment submitted
- purchase completed
Again, the pixel only creates tracking events, not direct ad platform calls.
Step 6: Configure Shopify Webhooks
Inside the Stape app, configure webhook subscriptions for:
- Purchase events
- Refund events
Webhooks allow Shopify to send order data directly to your server container.
However, Shopify webhooks have one major limitation.
They do not include browser cookies.
That means the webhook purchase event typically does not contain:
- Google Ads click IDs
- GA client IDs
- Meta identifiers
- Attribution parameters
Without these identifiers, attribution becomes difficult.
The Solution: Store Cookies Earlier in the Journey
To recover attribution data, we store cookie values before the user reaches checkout.
Later, when the webhook purchase arrives, we retrieve the stored values.
Step 7: Store Cookie Data at Checkout
When the user begins checkout, capture important identifiers from the browser.
Send the following data to your Server GTM endpoint:
- Checkout token or cart token
_gcl_aw_ga_fbp_fbc- Other attribution parameters if needed
This event is sent from the Web GTM container.
Step 8: Save Cookie Data in Stape Store
Inside the Server GTM container, create a:
Stape Store Write Tag
Trigger this tag when the checkout event occurs.
Use a unique key, for example:
checkout_ABC123
Example stored data:
{
"gclid": "EAIaIQobChMI...",
"ga_client_id": "GA1.1.1234567890.1234567890",
"fbp": "fb.1.1690000000000.123456789",
"fbc": "fb.1.1690000000000.AbCdEfGh"
}
Now your attribution data is safely stored before Shopify removes cookie headers.
Step 9: Receive the Purchase Webhook
Later, Shopify sends the purchase webhook to your Server GTM container.
This webhook includes:
- Order ID
- Checkout token
- Product information
- Customer information
But it still does not include cookies.
Fortunately, the checkout token allows us to perform a lookup.
Step 10: Retrieve Cookie Data Using Stape Store Lookup
Create a Stape Store Lookup Variable inside the Server GTM container.
Use the same key used earlier.
Example:
checkout_{{checkout_token}}
This retrieves the stored attribution values:
- gclid
- GA client ID
- fbp
- fbc
Step 11: Attach the Data to the Purchase Event
Now modify the webhook purchase event.
Attach the retrieved cookie values to the event payload before forwarding it to advertising platforms.
Send the enriched purchase event to:
- Google Ads
- GA4
- Meta Conversion API
- Other marketing platforms if needed
From the platform’s perspective, this event now looks like a fully attributed browser conversion.
Sending Events Through Google Analytics 4
GA4 is often used as the data transport layer for server-side tracking.
Create a GA4 Client in Server GTM
Inside the Server container:
- Create a GA4 Client
- Create a GA4 tag
- Leave the Measurement ID empty
- Trigger when Client Name = GA4
Configure the Web Container
Inside the Web container configuration tag, add:
server_container_url = https://tracking.yourstore.com
This routes GA4 events through your Server GTM container.
Create eCommerce Event Tags
Create GA4 event tags for:
- add_to_cart
- begin_checkout
- purchase
Each event should include:
- value
- currency
- items
Create Data Layer Variables:
ecommerce.valueecommerce.currencyecommerce.items
Setting Up Google Ads Server-Side Conversion Tracking
Inside the Server GTM container, configure the following tags.
Conversion Linker
Create a Conversion Linker tag and trigger it on all GA4 events.
This tag ensures click identifiers like gclid are properly processed.
Google Ads Purchase Conversion Tag
Create a Google Ads Conversion Tracking tag.
Add:
- Conversion ID
- Conversion Label
Trigger it on the purchase event.
If user data or product data is available, you can enable Enhanced Conversions for better attribution.
Final Thoughts
Conversion tracking in Shopify has become more complicated due to:
- Browser privacy restrictions
- Ad blockers
- Shopify checkout changes
While Shopify webhooks provide reliable order data, they lack the cookie information needed for proper attribution.
By combining:
- Web GTM
- Server GTM
- A custom tracking domain
- Shopify webhooks
- Stape Store for cookie storage
you can build a robust tracking infrastructure.
Capturing cookie values before checkout and restoring them when the webhook arrives ensures every purchase is properly attributed.
This approach helps you:
- Restore lost attribution signals
- Improve Smart Bidding performance
- Reduce discrepancies between Shopify and ad platforms
- Protect your ROAS reporting
Server-side tracking is no longer just an advanced setup. For Shopify stores relying on paid advertising, it has become a critical foundation for reliable analytics and advertising performance.

Leave a Reply