Don't have one? Create one ↗
Server-side tagging

Lesson 3 of 8

Your First Setup

You do not need to write any server code. The fastest path is a managed host; the most flexible is Google Cloud Run directly. Either way the flow is the same.

1Create server container2Provision hosting3Set tagging URL4Point GA4 at it5Verify

Step by step

  • In GTM, create a new container of type Server.
  • Provision the tagging server. Stape.io is the common managed option; Cloud Run is the direct Google option. You get a default *.run.app URL, then map a first-party subdomain like sst.yourdomain.com.
  • Add the GA4 client in the server container (it is there by default) so it can claim GA4 requests.
  • On the client side, set your GA4 configuration's server_container_url to your tagging URL so hits go to your server instead of straight to Google.
  • Open the server container's Preview and load your site, confirm the request arrives, the client claims it, and the GA4 tag forwards it.
// Client-side GA4 config parameter
server_container_url = "https://sst.yourdomain.com"

// Use a first-party subdomain (not the raw *.run.app)
// so cookies are first-party and the endpoint is harder to block.

Key takeaway

Create a Server container, host it (Stape or Cloud Run), map a first-party subdomain, add the GA4 client, then point your client-side GA4 tag's server_container_url at it and verify in the server Preview.