How to set up Google Tag Manager server container

Ira Holubovska

Ira Holubovska

Author
Updated
May 12, 2026
Also available in

To set up a GTM server container, do the following steps:

  • Create a Google Tag Manager server container 
  • Create a Stape account to host your server GTM container
  • Configure a custom tagging server URL
  • Create a Google Tag inside the Web GTM container
  • Create Google Analytics: GA4 Event tag
  • Create GA4 client inside server GTM container
  • Check and debug your setup
  • Set up a Custom GA4 Loader

By the end, you’ll have a fully functional GTM server-side container, capable of bypassing ad blockers, increasing cookie lifetimes, and much more.

Step 1: Create a Google Tag Manager server container

There are many common elements between web and server containers, like tags, triggers, variables, preview mode, etc. However, the setup of the GTM server-side container is more complex than that of the standard Google Tag Manager web container.

The main complexity of setting up a GTM server container is configuring the cloud environment to run the sGTM container. With the help of Stape, configuring cloud servers for sGTM will take only 5 minutes, and there is no need to hire developers. Besides that, Stape offers additional features on top of the Google Tag Manager server, like bypassing adblockers, increasing cookie lifetime, sending offline data, etc.

This video shows how to set up a GTM server-side container

Below is the step-by-step guide on how to set up GTM server-side container.

1. Open your WEB Google Tag Manager container https://tagmanager.google.com/.

Click Admin. Under the container column, click +

Set up server GTM

2. Type the container name, choose Server, and click Create.

Set up server GTM

3. Choose Manually provision tagging server, copy your container config and paste it in any text editor. We will need it for the next steps.

Set up server GTM

Step 2: Create a Stape account to host your server GTM container

1. Go to stape.io and create an account or log in.

Log in or sign up to access Stape

2. Click Create container on the top right. 

Click "Create container"

3. Enter your container details:

  • Container name. The name does not necessarily have to be the same as the container name in your server GTM.
  • Container configuration - paste Container Config that you copied from your Google Tag Manager Server Container.
  • Server location - for best performance, choose the server location that’s closest to where most of your clients are. See the list of available server locations here. If you have traffic from different regions, you can select the Global multi-zone server location option. It will automatically route incoming requests to the nearest available zone based on the user’s IP address.

Then click Create Container.

New container

4. Choose a plan for your container. You can start with a Free plan. Click Continue with a Free plan.

Stape pricing plans

5. You will see the status of your container, container config, and plan name. It takes around 5 minutes to deploy a server container. Please reload the page to update the status. If the Google Tag Manager server-side setup was done correctly, you should see the status Running

Running container on Stape

Step 3: Configure a custom tagging server URL

You can use a custom tagging server container URL to set up first-party cookies. Custom tagging server URL or custom domain should share the same domain as your website. For example, if your website domain is example.com, then the tagging server URL should look like ss.example.com. 

  • Same origin
  • Subdomain
  • Default domain
Three ways to set up a custom domain
A custom domain ensures that you handle tracking requests directly on your own domain, rather than relying on a third-party service. If you haven’t worked with custom domains in server-side tracking before, we have a blog article that explains different ways of setting up a custom domain: Server-Side GTM Domain Guide.

But here, we will cover custom subdomain setup:

Step 1. Add your custom domain

Сhoose your container on Stape, scroll down, and click Add custom domain.

How to add a custom domain in the Stape admin

Add Subdomain name - it can be any name that works for you, just be sure to avoid using phrases specific to advertising or tracking: ad, gtm, stgm, tracking, analytics, metrics, stape, gtag, etc.

Step 2. Add CDN

A Content Delivery Network (CDN) distributes your website's assets across a global network of servers to reduce latency and improve load times for users in different locations. It is useful if your audience is geographically distributed or if you want to improve cookie tracking and data accuracy.

By default, the CDN is disabled, which means JavaScript files (like gtm.js, gtag.js, and analytics.js) are served directly from the server location where your sGTM container is hosted. Effectively, it bypasses both Stape Global CDN and Own CDN options and gives you a direct, unproxied connection between your site and the sGTM container.

Important: please consider your country's privacy regulations before setting up a CDN.

To enable the CDN, click the Add CDN toggle and select one of the following options:

CDN toggle
  • Stape Global CDN - loads scripts from a server closest to your website visitor's location, which reduces latency and improves page load times for geographically distributed audiences. We will use the Stape Global CDN in our setup. This feature is free and available for all Stape sGTM containers.
  • Own CDN (incompatible with the Automatically (via Entri) connection option) - helps route sGTM custom domain and proxy sGTM traffic through the DNS provider of your website. In this case, the IP addresses of your website and the custom domain of the sGTM will match, and server-side cookies will be considered as first-party. As a result, it gives the ability to increase cookie duration.
Own CDN selected

Step 3. Select the "How to connect" method

 Next, in the How to connect section, there are two ways of connecting a custom domain to your container:

"How to connect" options
  • Automatically (via Entri)

The easiest way to connect domains. Log in with your DNS provider details via Entri, and give us one-time permission to connect your domain. That's it, you can proceed directly to Step 5 to verify your domain; no manual configuration is required.

Automatic connection via Entri
  • Manually

With this option, you have to add DNS records manually to your hosting provider to connect your subdomain to Stape.

Manual connection selected

After you add a custom subdomain to your container, you will see DNS records that should be created to verify the custom domain. The DNS record depends on the server location and the CDN option you choose. In the next step, we show how to add DNS records.

Step 4. Add DNS records (for the manual connection method)

By default, subdomain verification is performed with CNAME records, but you can verify your subdomain with A and AAAA records if you need to (usually in cases when you need to avoid adding duplicated records).

We will cover both options below with a step-by-step guide on how to create records using Cloudflare. But you can use any other provider.

Adding a custom domain with a CNAME record

You must create one CNAME record if you do not use Stape Global CDN and two records if you use Stape Global CDN.

1. Log in to your domain name service and create a new DNS record for the subdomain you want to use. To do it, click three dots and choose Configure DNS next to your domain name on the account home page.

Configure DNS

2. Click Add record.

"Add record" button

3. Go back to your Stape account and input the record you see in the account. Make sure that the Proxy status is turned off.

CNAME records in the Stape admin

We use Stape Global CDN, so we create two CNAME records:

CNAME record
Additional CNAME record (for the Stape Global CDN option)
Adding a custom subdomain with A and AAAA records
Please note that A/AAAA records are incompatible with enabled CDN.

1. If you need to verify your custom subdomain using A and AAAA records, add the custom subdomain to the container and make sure that the CDN toggle is switched off.

Click Advanced settings and tick the Use A records instead of CNAME records box. You will see DNS records that you should add inside your Stape container. The DNS records you should configure vary depending on the server location.

"Use A records instead of CNAME records" checkbox

2. Log in to your DNS account and add the records you see in your Stape account. On the account home page, next to your domain name, click three dots and choose Configure DNS.

Configure DNS

3. Click Add record.

"Add record" button

 4. Then, create the records you see in your Stape account. Make sure that the Proxy status is turned off.

Take the values for your DNS records from the Stape account:

A/AAAA records in the Stape admin

As a result, you will get two DNS records:

A record
AAAA record

Step 5. Verify your domain

Once you've entered the DNS records to your DNS provider, return to the Stape container page where you've been configuring the custom domain and click Verify.

"Verify" button

Wait for Stape to finish verifying your custom domain (when the container status bar changes from Verifying to Ready). Usually, it takes 2-3 hours to verify the custom domain. For some DNS providers, verifying records might take up to 72 hours. We will email you once the custom domain is verified or any error is detected.

If you face any problems with domain verification, please follow our guide on troubleshooting a custom domain.

Status "Ready" in the Stape admin

Step 6. Add tagging server URL and update your website script

Go to your Google Tag Manager server containerAdminContainer Settings → change Tagging server URL to your subdomain.

Server container URL in GTM

Update the script

If you use a custom domain, updating the Web GTM script on your website is highly recommended. This tweak will load gtm.js from your domain. To do so, replace the default domain googletagmanager.com with the custom domain you set up in the previous step.

Alternatively, you can automate this process with the Custom Loader power-up. Instead of manually editing the GTM script, Custom Loader generates a ready-to-use code snippet that loads GTM and GA4 scripts directly from your custom domain. This saves your time, makes your tracking scripts more resilient to ad blockers, and assures all cookies are treated as first-party.

Custom Loader power-up interface

Step 4: Create a Google Tag inside the Web GTM container

Open your Web container, create a new tag - Google Tag. Add your Google Tag ID.

In the section Configuration settings add the following parameters:

  • Name: server_container_url.
  • Value: Enter the URL you've created.

Add trigger to GA4 tag. Normally it should trigger on all page views.

Add trigger GA4 tag

Optional: You can also create a Google tag: Configuration settings variable that will predefine Google Tag settings if you need to use multiple Google Tags on your website and do not want to add settings for each of the tags manually.

Create a Google tag: Configuration settings variable

These parameters can be, for example, a setting that defines whether you want to send a page view event every time a Google Tag triggers, set UTM parameters, client ID, etc. There is a list of standard Google Tags configuration parameters.

Step 5: Create Google Analytics: GA4 Event tag

To set up the GA4 event, go to the tags section and create a new tag with the tag type Google Analytics: GA4 Event. Add your GA4 ID and the event name; there is a list of standard event names.

Create a GA4 Event tag

Step 6: Create GA4 client inside Server GTM container

Open Google Tag Manager Server container → click Client → create GA4 client and save it → go to Tags and set up GA4 tag. Remember that GA4 automatically sends not only pageviews but also some other events.

Inside Event Name, choose variable {{Event Name}} → add trigger Client Name equals GA4.

Tag configuration
Trigger configuration

Step 7: Check and debug your setup

How to publish the GTM container that you created on the server side? Open the Web and Server container preview modes and check that you see GA4 requests. Then, publish the update inside the server and web Google Tag Manager containers.

Check and debug your setup

Step 8: Set up a Custom GA4 Loader

You can make Google Analytics 4 server-side tracking even more accurate by using a custom GA4 loader. This will allow GA4 to work around any blocking tools, such as ad blockers and other privacy-related technologies that aim to prevent trackers from gathering data about visitors' activities. As a result, you'll see the complete picture of users visiting your site and have more data for ad optimization and custom audiences.

How to set up Custom Loader:

1. Log in to your stape.io account.

2. Open the sGTM container → Click Power Up.

3. Click Config Custom loader power-up → add your WEB GTM ID → You will see updated web GTM code → Copy this web GTM script and add or replace existing web GTM script on your site.

Custom Loader
How to set up Custom Loader

4. Once you've updated the web GTM code and set up server-side GA4, you can check modified GTM and GA4 requests in the network.

Google Tag Manager request URL should look like this:

Tagging server URL/stape container identifier.js?st=web GTM ID without letters GTM.

In our case, it's https://load.gtm.stape.dog/covxbvwx.js?st=PMVQSJH

Google Tag Manager request URL

GA4 request URL should look like this:

Tagging server URL/gt+stape container identifier.js?id=GA4 identifier.....

In our case, it's https://load.gtm.stape.dog/gtcovxbvwx.js?id=G-0SME9XLYER

GA4 request URL

Google Tag Manager server container: real Stape users' problems solved

In this thread, a user was unsure how to configure their Google Tag Manager server container and asked whether there was a “correct” setup. The issue turned out to be a misunderstanding: there is no single right or wrong configuration - it depends entirely on what data you need to send and which platforms you’re integrating with. Because you can’t diagnose a setup from just a container ID or sGTM URL, the solution was to review the full container configuration, and the recommendation was to involve a tracking specialist if you’re unsure how to structure events.

FAQ

A GTM (Google Tag Manager) container is a collection of tags, triggers, and variables used to manage tracking and marketing codes on a website or mobile app. It acts as a digital workspace that helps marketers organize and control their tags without needing to modify the site’s code directly. A single container can hold multiple tags and rules that determine when and how those tags are fired. There are specific container types tailored for websites, AMP pages, Android apps, iOS apps, and server-side implementation.

A GTM server container is a special type of container that runs on a server instead of in a browser or app. It helps move tracking tasks from the user’s device to a secure server. This gives more control over data and helps protect user privacy.

A GTM container is used to manage tags directly in a website, AMP page, or mobile app. It runs in the user’s browser or app and helps track things like page views, clicks, and conversions. A GTM server container, on the other hand, runs on a server you control. Instead of firing tags in the browser or app, it processes them in a secure server environment. This gives you more control over your data and improves privacy.

Conclusion

That’s it. Now, you’ve set up a server container, and Google Analytics runs via your server container. If you want to load GA within your domain and make GA request 1st party follow these steps to use a custom subdomain. And our team of experts can help!

And if you also want proof of your skills, certification can help you stand out. It shows clients or employers that you understand both browser and server-side setups and that you’ve learned them in depth. 

Want to switch to server-side?

You can do it for free at Stape! Click Try for free and explore the advantages!

Try for free
author

Ira Holubovska

Author

Ira has 10+ years of digital marketing experience, with the last 5 focused on server-side tracking. She understands how and when it works across various digital marketing scenarios.

Comments

Try Stape for all things server-side