Set up a server GTM container and deploy it on SGTM.space
A server container is a second GTM container that runs on a server instead of in the browser. Your website sends its data to that server first, and the server forwards it to GA4, Google Ads, Meta and the rest. In this lesson you create the container in GTM and let SGTM.space host it on a subdomain of your site, so there is no Google Cloud project to manage.
Beginner 10 min read
What you will learn
- Create a server container in Google Tag Manager and find its Container Config.
- Deploy the container on SGTM.space in the region closest to your visitors.
- Point a subdomain such as
sgtm.example.comat it with one CNAME record. - Check that the tagging server answers before you connect GA4 to it.
Before you start
- A Google Tag Manager account with Publish access (lesson 1 covers the web container).
- Access to the DNS settings of your domain (your registrar, hosting company or Cloudflare).
01 Choose the subdomain first
The tagging server should live on a subdomain of the site you measure, for example sgtm.example.com for www.example.com. Requests to your own domain are first-party: browsers keep their cookies longer and fewer blockers match them.
- Use a short, neutral name such as
sgtm,dataormetrics. Avoidgtmoranalytics, which some blocklists match. - Use the same registrable domain as the website.
sgtm.example.comworks forshop.example.comtoo. - Do not reuse a subdomain that already points somewhere else.
02 Create the server container in GTM
Server containers are created in the same GTM account as your web container, but as a separate container with the Server target platform.
- 1 Open tagmanager.google.com, go to your account and click Create Container.
- 2 Name it after the site (for example
example.com - server) and choose Server as the target platform. - 3 In the setup dialog choose Manually provision tagging server.
- 4 Copy the Container Config string. It is a long base64 value that starts with
aWQ9R1RN.
aWQ9R1RNLVhYWFhYWFgmZW52PTEmYXV0aD1hYmNkZWZnaGlqa2xtbm9w03 Deploy the container on SGTM.space
Sign up at SGTM.space and verify your email with the 6-digit code. Then open Containers and click New container.
- 1 Name: anything that helps you recognise the container later. It is never shown publicly.
- 2 Domain: the subdomain you chose, for example
sgtm.example.com. - 3 Google container config: paste the Container Config string from GTM.
- 4 Region: pick the one closest to most of your visitors (Europe, US East or Asia).
- 5 Click Create and provision.
04 Add the CNAME record
Open the DNS tab of the new container. It lists the exact record to add. For the main domain it is a single CNAME that points your subdomain at the endpoint of the region you chose.
Type: CNAME
Name: sgtm
Value: eu.sgtm.space
Proxy: DNS only- 1 Sign in where your domain DNS is managed and open the DNS records.
- 2 Add a CNAME record. Copy the name and value from the DNS tab exactly.
- 3 Save it, go back to SGTM.space and click Check DNS next to the record.
Most records resolve within a few minutes, some providers take up to an hour. When the record shows Ready, SGTM.space issues the HTTPS certificate for the subdomain automatically.
05 Check that the server answers
Once the container status is Ready, the tagging server answers on your subdomain. The quickest check is the health endpoint, which should return 200 OK.
curl -i https://sgtm.example.com/healthzThen open the server container in GTM and click Preview. A new Tag Assistant tab opens on your subdomain. It stays empty until data arrives, which is what the next lesson sets up.
- The container status in SGTM.space is Ready.
- The DNS record shows Ready.
-
https://sgtm.example.com/healthzreturns 200. - GTM Preview for the server container opens without an error.
Frequently asked questions
Do I need a Google Cloud account?
No. SGTM.space runs the tagging server and the preview server for you. You only need the Container Config from GTM and access to your DNS.
Can I change the region later?
Create a new container in the other region with the same Container Config, move the CNAME to the new endpoint and delete the old container once traffic has moved.
Why does Check DNS still fail after I added the record?
Usually the record has not propagated yet, the name was entered with the domain twice (some panels add it automatically), or Cloudflare proxying is on. The debugging lesson lists the common causes.
Ready to put it into practice?
Deploy a server GTM container on your own domain in a few minutes. The Free plan needs no card.
Create a free account