Table of Contents
If you’re looking to get more accurate data from your website, setting up server-side tagging (SST) with Google Tag Manager (GTM) is a great place to start. This approach is becoming crucial for digital marketers and analysts who need resilient tracking in the face of tightening privacy regulations and aggressive browser extensions.
In this post, we will walk you through the concept of GTM server-side tagging, its significant benefits, key considerations, and an overview of how to configure this setup using Stape, focusing on sending Google Analytics data through your own server.
1. How Does Server-Side Tagging Work?
To appreciate SST, it helps to first understand the traditional method: client-side tracking.
Client-Side Tracking: Google Tag Manager is installed directly on your website. When a user visits, GTM runs in their browser and fires tags (e.g., GA4 event tags), sending data directly from the browser to vendor servers, like Google’s.
Server-Side Tracking (Hybrid Setup): The flow changes slightly. GTM is still installed on the website and fires tags, but the data is first sent to your own server-side GTM container. Your server then processes that data before forwarding it to analytics vendors like Google Analytics.
For platforms like Google Analytics 4 (GA4), it is highly recommended to use this “hybrid” setup, which mixes client-side and server-side components, as the client-side Google Tag still performs necessary heavy lifting on the website. This extra layer of server control helps improve loading speeds and ensures your tracking is more resilient to interference from browser extensions.
2. The Core Benefits of Server-Side Tagging
Server-side tagging is a technical investment, but it delivers real benefits that impact data quality and site performance:
Reduce Page Load Burden
Traditional tracking necessitates loading multiple scripts in the browser, which can significantly slow down page loading speed.
With SST, you load just one main script on your site, send the data to your server, and let the server handle the rest—like forwarding data to Google Analytics, Facebook, or other tools. This approach translates to faster pages and less browser clutter.
Control What Data You Send to Vendors
When using third-party scripts client-side, they often collect more information than intended (such as device info, URLs, and screen size). Some tools may even use fingerprinting techniques to identify users.
Server-side tagging acts as a critical filter. You gain control to decide precisely what data gets passed along. For instance, you can remove or hash Personally Identifiable Information (PII) before it ever reaches platforms like Facebook Pixel or Google Ads, which reduces the risk of PII leaks. In this setup, vendor tools like Facebook Pixel communicate with your server, preventing them from accessing optional data usually available in the visitor’s browser.
Reduce the Impact of Ad Blockers
Even with user consent, browser extensions frequently block tools like Google Analytics. Properly configured SST helps here by routing data not to Google Analytics directly, but to a custom subdomain you control, such as data.yourwebsite.com.
Currently, most ad blockers do not intercept requests made to custom domains, allowing your tracking to continue functioning. Making the request parameters less readable (obfuscation) is also an essential component for resilience.
Extend the Cookie Expiration on Safari (ITP)
Safari’s Intelligent Tracking Prevention (ITP) severely limits cookie persistence, often to 7 days or even 24 hours. If you set cookies from the server (rather than with JavaScript), you can extend their lifespan, potentially up to two years.
Note on IP Matching: For this cookie lifetime extension to work, the first two numbers of the IP addresses of your SGTM server and the website server must match. Solutions often involve using the same load balancer or using specific Cloudflare workers to ensure IP matching.
3. Drawbacks and Key Considerations
While the benefits are substantial, server-side tagging requires careful consideration:
Consideration
Detail
Not a Silver Bullet
SST is not a solution for all tracking problems. Although many clients notice an increase in conversion numbers and a decrease in acquisition costs (around 80-90% in one expert’s experience), there is no 100% guarantee. Furthermore, SST will not help with data recovery from unconsented users; you must still obtain valid consent if required by local laws.
It’s a Paid Solution
While the GTM server-side container is free, running it on a live site requires paying for hosting. Hosting options include Google Cloud Platform (GCP, approximately $90/month / £71/month) or specialised SGTM-hosting providers like Stape, which starts around $20/month / £16/month and is usually more affordable. Costs escalate with traffic volume.
Requires Technical Skill
Server-side tagging demands a more technical skill set than client-side GTM. You need to understand data flow, server interaction, and potentially how to write or debug JavaScript.
More Difficult to Debug
When issues arise, debugging involves checking both the client-side GTM setup and the server-side container, adding complexity to the workflow.
Ultimately, the benefits generally outweigh the potential drawbacks, and testing the setup first often involves no cost.
4. Overview of Configuration Steps with Stape
The process of configuring server-side tagging requires several distinct steps:
Create a Server GTM container: This should ideally be within the same GTM account as your web container. You must select “Server” as the container type and choose to manually provision the tagging server.
Host the container with Stape: Navigate to Stape.io, create an account, select the server location (EU recommended if many visitors are from the European Union), paste the GTM container configuration, and choose a pricing plan (a free plan is available for testing).
Map a Custom Domain: A server-side GTM container is considered “worthless” without a custom (sub)domain. You can choose a subdomain (e.g., data.yourwebsite.com) or the preferred same-origin setup (e.g., yourwebsite.com/xyz).
To start, you must create a subdomain in Stape, even if planning a same-origin setup later. This requires adding CNAME records to your DNS (e.g., Cloudflare).
Implement Same-Origin Routing (if applicable): If you choose the same-origin approach, you need to create a Cloudflare Worker (which has a free tier for up to 100,000 requests per month). This worker receives tracking requests to your main domain path (e.g., yourwebsite.com/som) and redirects them internally to your SGTM server. Configuration rules for SSL and setting a custom request header are also needed in Cloudflare.
Create Client(s): Clients in SGTM (like the default GA4 client) listen for incoming requests and determine how data should be handled. A single client can claim a request, allowing multiple tags to fire based on that data (e.g., sending to GA and Facebook Conversions API).
Update the Web GTM Setup: Modify your GA4 Config tag (or Google Tag) in the web container to point to your new custom server URL (e.g., https://yourwebsite.com/som). This is done by adding the server_container_url parameter and setting its value to a constant variable containing your full server URL.
Send Data from SGTM to Vendors: In the server GTM container, create a new Google Analytics: GA4 tag. This tag forwards the incoming GA4 request to Google’s servers. A trigger should be set to fire only when the {{Client Name}} equals “GA4”.
Proxy SGTM and GA Requests (Custom Loader): To further increase resilience against browser extensions, use Stape’s Custom Loader power-up. This allows your GTM container and Google Tag to load from your own domain rather than Google’s. This feature also enables the GA4 ad block bypass, which modifies the request URL to obscure parameters, making them harder for extensions to identify and block.
Publish All Changes: Ensure you publish your changes in both your web container and your server-side container to fully deploy your new setup.
Final Words
Congratulations! You have taken a significant step toward achieving more accurate data collection. Setting up your first server-side tagging environment—from hosting with Stape to mapping a custom domain—is a solid accomplishment.
This initial setup is just the beginning. From here, you can move on to powerful advanced techniques, such as implementing the Facebook Conversions API, sending data to Google Ads, and enriching event data with information fetched from external systems like your CRM.

