GTM Server-Side Container Setup
Server-side GTM container setup on Google Cloud Run. Custom domain, client templates, tag templates, monitoring, the cost model, and Stape.io as the managed alternative.
What a GTM server container actually is
A GTM server-side container is a Node.js application running on Google Cloud Run that receives HTTP requests from your website (or app, or backend), processes them through GTM's logic, and forwards events to vendor endpoints (Meta CAPI, Google Enhanced Conversions, TikTok Events API, GA4 Measurement Protocol). It is GTM, but server-side. The configuration model is the same — tags, triggers, variables — but it runs on your server instead of in the user's browser.
Why a server container, not just web GTM
Server-side GTM does three things web GTM cannot:
- Receives events server-to-server, bypassing ad blockers and ITP throttling.
- Enriches events with first-party data (hashed email, customer ID, internal user ID) that the browser does not have access to.
- Forwards events to Conversions API endpoints with full deduplication using event_id matching against the corresponding Pixel events.
For the foundational discussion, read server-side vs client-side tracking.
Two implementation paths
1. Google-hosted on Cloud Run
- Create a server container in GTM (tagmanager.google.com → create new container, target: Server).
- Provision via the Cloud Run automated setup. GTM generates a Cloud Run service in your Google Cloud project.
- Set up a custom subdomain (data.yoursite.com). Add an A record or CNAME in your DNS pointing to the Cloud Run service.
- Configure your client-side gtag.js to send to your custom subdomain instead of www.google-analytics.com.
- Install client templates (GA4 client, Meta CAPI client, TikTok client) in the server container.
- Configure tags for each downstream destination.
Cost: roughly $40 to $120 per month at moderate volume, $200 to $400 at high volume. Free tier covers some workloads.
2. Stape.io (managed)
Stape hosts your GTM server container on their infrastructure with a custom domain, automatic SSL, monitoring, and pre-built enhanced templates. Plans from $20 per month. Setup time: 25 to 45 minutes from scratch.
When Stape wins: you do not have a DevOps team. When Google-hosted wins: you have Google Cloud expertise and want full control.
Custom subdomain
The custom subdomain (data.yoursite.com) is what makes server-side GTM resistant to ad blockers. Ad blockers maintain lists of known tracking domains (www.google-analytics.com, connect.facebook.net, etc.). Your custom subdomain is not on those lists. As long as the subdomain is set up correctly with proper SSL and DNS, ad-blocker bypass is automatic.
What goes in the server container
- Clients: entry points that parse incoming requests. GA4 client, Meta CAPI client, TikTok client, etc.
- Tags: destinations that forward events out. GA4, Meta, TikTok, LinkedIn, Snap, Pinterest, Reddit, all with their own server-side tag templates.
- Variables: the same dataLayer-style variables you know from web GTM, plus server-specific ones (request headers, IP address, cookies).
- Triggers: events that fire tags. Most server-side triggers are based on the event_name parameter.
Monitoring
Cloud Run gives you basic monitoring out of the box (request count, latency, errors). For deeper monitoring, integrate with Cloud Monitoring or use Stape's built-in dashboards. Track: request volume per client, errors per tag, latency per destination, deduplication match rates.
Common server container failure modes
Tags timing out
Cloud Run instances time out at default 60 seconds. Vendor endpoints (Meta CAPI, especially under load) can take longer. Configure tag timeouts explicitly. Use Cloud Run's max instances setting to scale horizontally.
Custom subdomain SSL errors
SSL certificate not issued or DNS propagation incomplete. Wait 24 hours and verify with a tool like SSL Labs. Stape handles this automatically; Cloud Run requires manual setup.
Events firing twice (web and server)
Web GTM still firing the Pixel directly while server GTM also fires CAPI. Each side counts the conversion. Solution: pass shared event_id from web GTM to server GTM and let the vendor dedupe.
Container outgrowing free tier
High-volume accounts (10+ million events per month) start incurring serious Cloud Run charges. Optimize by reducing instance memory, increasing concurrency per instance, and using min-instances 0 if traffic is bursty.
What to read next
Sister pages: advanced GTM setup, iframe tracking with GTM, dataLayer guide. For the why, read server-side vs client-side tracking. For platform-specific setup that runs through the server container, read the CAPI section.