Ad blockers and browser privacy updates block client-side tracking scripts. Server-side Google Tag Manager (sGTM) deployed on your own domain solves this by collecting data server-to-server instead of in the browser. This approach preserves analytics signals, keeps conversion tracking intact, and avoids third-party cookie dependency.
The setup requires a subdomain, a server endpoint, and configuration in Google Tag Manager. The payoff is cleaner data, higher tracking coverage, and reduced reliance on ad-blocked pixels. This post covers the architecture, step-by-step deployment, and how to avoid the most common failure modes.
What Server-Side Tag Manager Does (and Does Not)
Server-side Tag Manager is a Google Tag Manager container that runs on your server instead of in the visitor's browser. When a user lands on your site, a lightweight client-side script sends events to your server. Your server then forwards that data to analytics platforms, ad networks, and marketing tools.
The key advantage: your server is not subject to ad blockers or browser privacy features. Ad blockers only block requests from the browser to third-party domains. When your server sends data to Google Analytics or Meta, it looks like a server-to-server request, not a marketing pixel.
What sGTM does preserve: Page views, user actions, conversion events, and custom parameters. What it does not: It does not restore third-party cookies or bypass Intelligent Tracking Prevention (ITP) on Safari. It also does not hide your intent from privacy-focused users; it simply changes how the data moves.
Architecture: Subdomain, Server, and Data Flow
A working sGTM setup has three parts: a first-party subdomain, a server endpoint, and the Tag Manager container itself.
First-Party Subdomain
You create a subdomain on your own domain (e.g., events.yoursite.com or analytics.yoursite.com). This subdomain points to your server infrastructure. Because it is your domain, browsers and ad blockers treat requests to it as first-party, not third-party. This is the critical difference.
Server Infrastructure
Your server listens for incoming events from the client-side script and forwards them to downstream tools. The server can run on Google Cloud Run, AWS Lambda, Cloudflare Workers, or your own managed server. Most teams start with Google Cloud Run because it integrates natively with Tag Manager and has a free tier.
The server does not store data; it is a pass-through. It receives a request, adds or modifies headers/parameters, and forwards the request to Google Analytics, Meta, or other platforms. This is why it is called a "proxy" or "relay."
Client-Side Script
Your web page still needs a small script that collects events and sends them to your subdomain. This script is similar to the standard Google Analytics tag, but instead of sending to Google directly, it sends to your server endpoint. The script is lightweight and not blocked because it talks to your own domain.
Step-by-Step Setup
1. Create a Server-Side Tag Manager Container
Log into Google Tag Manager. Create a new container and select "Server" as the container type. Google will assign you a container ID (looks like GTM-XXXXXX). This container will hold the rules and tags that process incoming events.
2. Deploy the Server Infrastructure
Choose a hosting platform. Google Cloud Run is the most common choice for sGTM because Google provides a server-side Tag Manager setup guide with templates. You will create a service account, deploy a containerized application, and assign it a public URL.
The URL will look like https://gtm-server-XXXXX.a.run.app. This is your temporary endpoint. You will later point your subdomain to this endpoint.
3. Point Your Subdomain to the Server
In your domain registrar or DNS provider, create a CNAME record for your subdomain. For example, create events.yoursite.com and point it to your Cloud Run service URL. DNS propagation takes a few minutes to an hour.
After propagation, requests to https://events.yoursite.com will reach your server-side Tag Manager container. Test this with a simple curl command or browser request to confirm the endpoint is live.
4. Install the Client-Side Script
Google provides a client-side script snippet for sGTM. It looks similar to the Google Analytics gtag snippet but sends to your subdomain instead of Google directly. Add this snippet to your website (usually in the page header or via Google Tag Manager itself).
The snippet takes a parameter that points to your subdomain. Example:
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GTM-XXXXXX', { 'server_container_url': 'https://events.yoursite.com' }); </script>
5. Create Tags and Routes in Server-Side Tag Manager
Inside your server-side container, you define routes and tags. A route is a rule that matches incoming events. A tag is an action (send data to Google Analytics, Meta, etc.).
Example route: "If event name is 'page_view', send to Google Analytics 4." You configure this by creating a route that checks the event type, then attaching a Google Analytics 4 tag to that route.
Start with one simple route: capture all page views and send them to GA4. Test this works before adding more complex rules.
6. Test End-to-End
Open your website in a browser. Use the browser's Network tab to confirm requests are going to your subdomain (not blocked). Check Google Analytics to confirm events are arriving. If events do not appear after 5 minutes, check the server-side Tag Manager debug view to see where the request failed.
Common Pitfalls and Fixes
DNS Not Propagating
If your subdomain does not resolve, the client-side script will fail silently and no events will be sent. Wait 1–2 hours after creating the CNAME record. Use a DNS lookup tool (e.g., nslookup events.yoursite.com) to confirm the subdomain points to your server.
Server Returns 403 or 404
The server endpoint requires a valid request format. The client-side script sends data in a specific shape. If the server rejects the request, check that the client-side snippet matches Google's latest template and that your server-side container is published (not in draft).
Events Arrive but with Wrong Data
Server-side Tag Manager can modify or enrich event data before sending downstream. If data is missing or incorrect, check your routes and tags. A common mistake is creating a route that is too specific (e.g., only matching a single page) when you meant to match all pages. Use the debug view to trace which route matched and which tag fired.
Ad Blocker Still Blocks Requests
If requests to your subdomain are still blocked, the issue is usually a blocklist rule that targets your domain or a specific URL pattern. Most ad blockers are less aggressive with first-party subdomains, but some block based on domain reputation or keyword matching. Check your browser console for blocked requests. If a request is blocked, try renaming the subdomain to something generic (e.g., api.yoursite.com instead of analytics.yoursite.com).
Cookies Not Persisting Across Requests
Server-side Tag Manager can set first-party cookies on your subdomain. These cookies help identify returning users. If cookies are not persisting, check that your subdomain is configured to accept cookies (usually automatic) and that your server is setting the Set-Cookie header correctly. Test with a cookie inspection tool to confirm the cookie exists after the first request.
When Not to Use Server-Side Tag Manager
Server-side Tag Manager is not required for every site. If you have low ad-blocker traffic, simple analytics needs, or no third-party integrations, client-side Tag Manager is simpler and sufficient.
sGTM adds complexity: you manage a server, DNS records, and an extra layer of configuration. If your analytics setup is straightforward (GA4 only, no conversions, no retargeting), the overhead may not be worth the gain.
Server-side Tag Manager shines when you have multiple downstream integrations (analytics, ad networks, CRM platforms) and need a single point of control. It also makes sense if ad-blocker traffic is significant (typically 15% or higher) and you need to preserve that data.
What to Do Next
Start with a single route and tag (page views to GA4). Test that data flows correctly before adding more integrations. Once the basic setup works, you can add routes for custom events, conversions, and other platforms. server-side tracking setup can be assessed for your specific infrastructure if you need help planning the deployment.
FAQs
Does server-side Tag Manager bypass GDPR or privacy laws?
No. Server-side Tag Manager changes how data moves, not what data you collect. You still need consent for tracking, and you still must honor user privacy choices. The subdomain is your domain, so the data is first-party, but consent and privacy policies remain your responsibility.
Will server-side Tag Manager slow down my website?
No. The client-side script is lightweight. The server forwards requests asynchronously, so it does not block page rendering. Latency is typically under 100 milliseconds.
Can I use server-side Tag Manager with Google Analytics 4 only?
Yes. Many sites start with GA4 and add other platforms later. Server-side Tag Manager is flexible; you add routes and tags as needed.
What happens to data if my server goes down?
Events sent while the server is offline are lost. This is why you should monitor your server uptime and set up alerts. Most teams use a reliable hosting provider (Google Cloud Run, AWS) with 99.9% uptime guarantees.
People Also Ask
What is the difference between client-side and server-side Tag Manager?
Client-side Tag Manager runs in the browser and sends data directly to third-party platforms. Server-side Tag Manager runs on your server and forwards data from your server. Server-side avoids ad blockers and third-party cookie restrictions.
Do I need server-side Tag Manager if I use a CDP?
A customer data platform (CDP) can replace some server-side Tag Manager functions. If your CDP collects data server-side and forwards to your analytics tools, you may not need sGTM. If your CDP sends data client-side, sGTM can complement it by ensuring data reaches your server even when ad blockers are active.
How much does server-side Tag Manager cost?
Google Tag Manager itself is free. Hosting costs depend on your platform. Google Cloud Run charges based on requests and compute time; most sites pay $0–50 per month. AWS Lambda and Cloudflare Workers have similar pricing models.
Can server-side Tag Manager track users across domains?
Yes, but with limits. Server-side Tag Manager can set cookies on your subdomain and pass user IDs across your owned domains. Cross-domain tracking requires additional configuration and user consent. Third-party cookie tracking (across unrelated domains) is not possible with sGTM.
What if my hosting provider does not support server-side Tag Manager?
You can deploy sGTM on any server that supports containerized applications or serverless functions. Google Cloud Run is the easiest, but AWS Lambda, Heroku, and self-managed servers work too. Check your provider's documentation for deployment steps.
How do I debug server-side Tag Manager when events are not arriving?
Use the debug view in your server-side Tag Manager container. It shows incoming requests, which routes matched, and which tags fired. Check your client-side browser console for errors. Verify DNS resolution and server uptime. Most issues are DNS misconfiguration or a mismatch between the client-side script and the server-side container.
Does server-side Tag Manager work with iOS and Android apps?
Server-side Tag Manager is designed for web. Mobile apps can send events to a server endpoint, but you would need custom implementation. For mobile, consider using Firebase or a mobile-specific analytics solution.
Can I use multiple server-side containers?
Yes. You can create multiple sGTM containers for different purposes (one for analytics, one for ads). Each container gets its own endpoint, and you route traffic accordingly. This is useful for large organizations with separate teams managing different platforms.
If this post is wrong, outdated, or you would take a different path
I write from work I have done on real sites. Search products change, and a step that was right when I published can go stale. I can also be wrong about the method.
If you disagree with the approach, the facts, or the outcome, I want the detail. Tell me what is off, what you would do instead, and where you saw it. I use that to correct the post so the next reader is not stuck.
This is not a comment thread. Use Contact me so the note is tied to this post and I can reply.
You are sending feedback for
First-Party Server-Side Google Tag Manager: Preserve Analytics Past Ad Blockers
Tracking & Attribution