Server-side GTM setup on Cloud Run
Hosting on Cloud Run
The server container can be provisioned automatically from Tag Manager or manually in Google Cloud. It needs a tagging server for live traffic and a preview server for the Preview feature. For production, Google recommends running at least 2 instances to reduce the risk of data loss during an outage, and setting a billing alert to avoid unexpected charges (Google).
First-party domain
Google says the tagging server and your website must share a domain to get first-party benefits; on the cloud provider's default domain, server-set cookies aren't available. Same-origin serving (such as www.example.com/metrics) is Google's best practice, and a subdomain (metrics.example.com) gives the same cookie benefits with a simpler DNS setup (Google).
Events from the web container reach the server container through the GA4 client, and Meta's Conversions API tag forwards them to Meta. When the same event is sent from both the browser pixel and the server, both use the same event_name and the same event_id (or external_id and fbp) so Meta can deduplicate them (Meta). For the term itself: CAPI.
Enhanced conversions
Enhanced conversions send first-party data such as email addresses or phone numbers to Google Ads, hashed with SHA256. With server-side GTM, when your scripts load through the server container, the data goes from the browser to it, and the Google Ads tag encrypts it before it reaches Google (Google).
Data control
Google notes that only you can access data in the server container until you choose to send it elsewhere, and you decide which fields go to which platform (Google). For a broader project that includes cross-platform validation and monitoring, see our server-side tracking service.