Lesson 17 of 18
Server-Side GTM
① Connect your GTM container
Paste your container ID to load it into this page. It only ever runs here.
Advanced: use a specific environment
Every tag you've built so far runs in the browser, where ad blockers, ITP cookie limits and a heavy page all chip away at your data. Server-side GTM moves tag execution off the browser: the page sends one hit to a server container you own, and the tags fan out from there, server to server.
A GA4 client in the server container claims the incoming request and builds an event data object; server-side tags (a GA4 tag, a Meta Conversions API tag) then relay it to each platform. A shared event_id lets a platform deduplicate the server hit against the browser pixel, so one purchase is counted once.
This is the one topic that genuinely needs a backend (a Cloud Run or Stape container on a first-party subdomain), so the steps below are a guided simulation. Drive the request to see the whole lifecycle, then read the Server-side tagging and Container governance guides paired with this module.
Goal
Trace a hit from the browser to a server container and out to GA4 and Meta CAPI, deduped on event_id.
Build it in GTM
Create a Server container + host it
New GTM container of type Server, provisioned on Cloud Run or Stape, mapped to a first-party subdomain like sst.yourdomain.com.Point the browser at it
Set the client-side GA4 config's server_container_url to your tagging URL so hits route through your server.Add the GA4 client + GA4 tag
The GA4 client claims the request; the server-side GA4 tag relays it to Google.Add the Meta CAPI tag with a shared event_id
Read the same event_id the browser pixel used so Meta deduplicates the two into one conversion.
Debug in Tag Assistant
Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see