Skip to main content

Server-side GTM and the Meta Conversions API · Part 1: Server-side GTM, from zero

Chapter 4.1 · 1 of 22 · 3 min

Server container architecture

In the first book your container was called `GTM-XXXXXXX`, and it was a web container.

Free to read

In the first book your container was called GTM-XXXXXXX, and it was a web container. Server-side GTM adds a second container, with its own ID, and its job is completely different.

The difference in one line: the web container runs in the browser, the server container runs on your server. A web container holds Tags, Triggers and Variables. A server container holds Clients, Tags, Triggers and Variables. That word Client is the new part, and it is the core of the whole thing.

Client, Event Data and Tag: three stages

Before, the browser sent GA4 hits straight to www.google-analytics.com and Meta hits to connect.facebook.net, and every one of those domains is on ad blocker lists. Now the hits go to gtm.yourdomain.com, your own domain, and from there the server itself sends separate requests to Google, Meta and TikTok.

Inside the server container, a request passes through three stages.

Stage one, the Client. When a request arrives, the container asks each of its Clients: is this yours? The Client that says yes claims the request. The GA4 Client takes requests whose path is /g/collect.

Stage two, Event Data. The Client turns the request into a structured object containing event_name, client_id, page_location and, for ecommerce, an items array. All your server-side variables read their values from this object.

Stage three, the Tag. Once the Event Data exists, the triggers are evaluated, and every tag whose conditions match fires.

When an event goes missing, your first question is whether a Client claimed it. If no Client claimed it, no event data was ever created, and there is no point wasting time debugging tags.

Steps

  1. In GTM, create a new container in your account (from the Admin screen, or from the account list).
  2. Name it yourdomain - server. Under Target platform choose Server, not Web.
  3. After you click Create, GTM offers two routes: Automatically provision tagging server and Manually provision tagging server. Do not choose either for now; only note down the container ID.
  4. Look at the left-hand menu: Tags, Triggers, Variables and Clients. Four items, and the web container had no Clients.
  5. Click Clients. The container already has at least one default client, including GA4. Open the GA4 one and look at its Priority and activation path settings, but change nothing.
  6. [SCREENSHOT: the left-hand menu of a GTM server container, showing Tags, Triggers, Variables and Clients as four separate items, with the container ID at the top]

What not to do

  • Do not look for server-side tags inside the web container, or the other way round. The tag lists of the two containers are completely different. In the server container you will not find a Meta Pixel tag; you will find a Conversions API tag. Newcomers lose half an hour searching here.
  • Do not delete the web container and put a server container in its place. A server container receives no data by itself. It only receives what someone sends it, and sending is the web container's job.
  • Do not use the same container ID in both places. If you install the web container snippet with the server container's ID, nothing runs on the page and no error appears in the console. It silently counts zero.

Proof

Your GTM account shows two containers, one Web and one Server, and the server container has a separate Clients item in its left-hand menu. And you can say in one line what a Client does: it claims the incoming request and builds the event data.

Want the full chapter list, or to jump to another chapter?

All chapters in the book