How to set up Google Tag Manager Server Container

May 14, 2024
Oct 4, 2020
Also available in

Collecting data about your website visitors is critical for analyzing and improving the online business presence, reaching users, and converting them into customers. 

However, collecting data is becoming more problematic because of Intelligent Tracking Prevention, AdBlockers, and a decrease in cookie lifetime. Google Analytics and other similar tools will start seeing fewer data about your website visitors and giving you less information to analyze. On the other side, tracking policies and rules make website owners strictly control what data about website visitors they share with 3rd party tools.

To help address these challenges, Google introduces a new feature – Server-Side Tagging to Google Tag Manager. 

What is Google Tag Manager Server-Side Tagging and Why Does it Matter?

Google Tag Manager (GTM) Server-Side tagging allows website owners to move third-party tracking pixels from their website and start tracking website visitors from the server. It means that the client browser will no longer process tracking pixels. It will be loaded directly from the server.

This approach provides the following benefits:

  • More accurate data;
  • Faster website load time;
  • Extra control over privacy.

Your digital marketing analytic tools (like Google Analytics) can run without executing 3rd party cookies on the client-side. With appropriate server containers set up, you will forget about heavy javascript, blocked 3rd party cookies, and incomplete data in analytics tools. 

If server-side tracking is hosted in your website’s subdomain, all requests will be considered first-party. Google has a detailed description of what is GTM server tracking and how it can benefit your website. 

How to set up Google Tag Manager Server-Side tagging on your website?

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

When setting up a server-side GTM container, the main complexity is configuring the cloud environment to run the sGTM container. We created a stape to simplify GTM server container configuration. 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 server Google Tag Manager, like bypassing adblockers, increasing cookie lifetime, sending offline data, etc.

👇 This video shows how to set up server Google Tag Manager container

Let's start setting up server Google Tag Manager:

1. First of all, you need to create a Google Tag Manager Server container. To do that, go to and choose the account where you want to make a container. Click Admin.

set up google tag manager server container 

2. Under the container column, click +.

create google tag manager server container 

3. Type container name, choose Server, and click create. 

select server in Google Tag Manager 

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

server google tag manager manually provision tagging server 

5. Create or login to your account in our service.

6. Once you received the email with the link and set your password, you need to click "Create Container". Add your container name, Container Configuration that you copied from your Google Tag Manager Server Container, and select server location. Click Create Container.

create container at stape

7. Once you click create, 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 setup was done correctly,  you should see the status “Running”. 

If you see “Error” please check that you’ve copied and pasted the correct container configuration. 

If the error repeats contact the support.

8. The key feature of server-side tagging is setting first-party cookies. You need to use a custom tagging server URL to enable this feature. Custom tagging server URL or custom domain should share the same domain as your website. For example, if your website domain is, then the tagging server URL should look like

If you want to add a custom domain, open the sGTM container on Stape, scroll to the domains section, type the domain name, and click Add domain. Once done, you will see DNS records that you should add.

set up custom domain server side tagging 

 Below is an example of DNS setup for CloudFlare.

add DNS records server-side tagging
add DNS records ss tagging

 9. Go back to the Google Tag Manager Server container -> Choose your server container -> Admin -> container settings -> paste tagging server URL.

set tagging server url in gtm

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

update google tag manager script stape

10. Inside the Web container, create a new tag of the tag Type 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. 

set up Google Analytics 4 server-side 

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.

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.    

11. 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

You can create a Google Tag: Event Settings variable that will help to share event parameters across several GA4 event tags or Google Tags. It can be, for example, user or product properties, and there is also a list of standard parameters for event settings. 

Google analytics 4 events settings 
google tag event settings variable

12. 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 pageview but some other events. Inside Event Name choose variable {{Event Name}}. -> add trigger Client Name equals GA4.

set up ga4 tag in the server container 
set up ga4 client in the server container 

13. Open the Server container preview mode and check that you see GA4 requests. Publish updated inside server and web Google Tag Manager containers. 

test ga4 trigger in the server container 

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!

Tagged with:gtm server

Host your GTM server at Stape