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 Version 1.5, updated October 9, 2026
On this page
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
k7q2x.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 k7q2x.example.com for www.example.com. Requests to your own subdomain are first-party, so the server can set HTTP cookies that most browsers keep longer than cookies set by JavaScript, and fewer blockers match them. Safari and iOS browsers still cap them at 7 days when the subdomain is a CNAME to another host, which is how SGTM.space works.
- Use a few random characters, such as
k7q2x. Filter lists have rules forgtm,sgtm,ssgtm,ss,sst,tagging,analyticsandtracksubdomains on any site. Names liketag,metrics,stats,data,tracking,collectormeasurehave no such general rule, but lists add them one site at a time. - Use the same registrable domain as the website.
k7q2x.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 usually 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. On the Accounts page click the ⋮ menu next to your account name and choose 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.aWQ9R1RNLVhYWFhYWFgmZW52PTEmYXV0aD1hYmNkZWZnaGlqa2xtbm9w
03 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. Creating a container takes three steps.
Step 1, your website. Enter the address of the site you measure and click Read my site. In a few seconds SGTM.space reads the page and suggests the settings for your container. If the site cannot be read, or you prefer to type everything yourself, click Skip and fill in by hand.
Step 2, your container. The form shows what the scan found, and you can change every field:
- 1 Subdomain: a few random characters on your site's domain are proposed, for example
k7q2x.example.com. Keep them or enter the subdomain you chose. - 2 Region: Europe is preselected. Pick the one closest to most of your visitors (Europe, US East or Asia).
- 3 Web GTM container ID (optional): the
GTM-XXXXXXXfound on your site is filled in. If the site runs several, pick the one that will send data to this server. With an ID, Turn on Better Loader for GTM-XXXXXXX is ticked by default. Google Tag Manager loads from your own subdomain once the loader's DNS record is verified and your site uses the Better Loader snippet instead of the GTM snippet. - 4 Name (optional): your site's address is proposed. Only your team sees it.
Step 3, server-side GTM (optional). Choose whether you connect the server container now or later, then click Create container.
Do you have the Container Config yet?
Choose I have my Container Config and paste the string from GTM.
Choose I will connect it later. You can already add the DNS records, run the website audit and, once the loader's record is verified, replace the GTM snippet on your site with the Better Loader snippet. Your page keeps sending its data straight to Google until the server runs.
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
k7q2x- Value
eu.sgtm.space- Proxy
- DNS only
Where is your domain's DNS managed?
- 1 In the Cloudflare dashboard, open your domain, then DNS and Records, and click Add record.
- 2 Choose CNAME as the Type and copy the Name and Target from the DNS tab exactly.
- 3 Switch Proxy status off, so it reads DNS only (gray cloud), and click Save.
- 4 Go back to SGTM.space and click Check DNS next to the record.
- 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. Once the record is in place, SGTM.space issues the HTTPS certificate for the subdomain automatically, usually within minutes. It also re-checks the record every few minutes, so you do not have to keep clicking Check DNS.
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 with the body ok.
curl -i https://k7q2x.example.com/healthyThen open the server container in GTM, go to Admin and Container Settings, enter https://k7q2x.example.com as the Server container URL and click Save. Now click Preview: a 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://k7q2x.example.com/healthyreturns 200. - GTM Preview for the server container opens without an error.
- The Server container URL in the server container's Container Settings is
https://k7q2x.example.com.
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 start before I have the Container Config?
Yes. Create the container and choose I will connect it later. The DNS records, Better Loader and the website audit are available right away: you add the records, run the audit and, once the loader's record is verified, paste the Better Loader snippet on your site. Until the server runs, your page keeps sending its data straight to Google. Paste the Container Config on the container's overview whenever you are ready, and the tagging server starts then.
Can I change the region later?
Yes, but a subdomain can belong to only one container at a time, even an inactive one. The simplest way is a new container on a new subdomain in the other region: point server_container_url at it and delete the old container once traffic has moved. To keep the same subdomain, the old container has to be deleted first. A Free container can be deleted right away, a container on a paid plan only after its plan is cancelled, at the end of the billing period.
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