Server-side GTM with multiple domains

Author
Stape
Published
May 19, 2022
Also available in

The first step to successfully web tracking is creating a detailed plan that describes what events and event data should be sent and when. This ensures the correct information gets collected, analyzed, and reported back to analytics tools like Google Analytics or Facebook.

Configuring server-side tracking should start even with an earlier phase - planning how to set tagging server.

Configuring a tagging server is relatively easy if you plan to use an sGTM container for one website. Just create a custom domain for the tagging server, set necessary DNS records, configure sGTM, and that’s it. But what should you do when using one server GTM container for multiple websites? When does it make sense to use one sGTM container for several websites? How should you map custom domains in this case? 

In this blog post, I will try to cover all questions related to server-side tagging for multi-domains and show how to set up a multi-domain tagging server using stape. 

When to use one sGTM for multiple domainsCopy link to this section

These are the three most popular use cases for utilizing one sGTM for several websites from my experience:

  • Localization. Site uses different domains for localization. For example, the English version is example.com, example.es - is the Spanish version, etc. 
  • Subdomains. Some parts of the website are located on subdomains. example.com - is the main site, but there are also blog.example.com, landing.example.com, etc.
  • Different domains but same niche. You might have several websites in the same niche and use one tracking property for all of your websites, for example, the same sGTM and UA for websites with domains, example.com, test.com, blog.com, etc.

Disadvantage of using one sGTM container for multiple domainsCopy link to this section

You might decide to use one server Google Tag Manager for multiple websites to reduce expenses on sGTM hosting. Though it really might decrease costs on running sGTM, we highly recommend using one sGTM on multiple domains when it is strictly necessary because a multi-domain setup makes managing sGTM tracking extremely complicated. 

Using one server GTM container for several websites can lead to an increase in the number of tags and triggers because you might have situations where it's necessary to create a separate tag or trigger, depending on the domain.

Besides server-side GA, you will want to set up ss tracking for other platforms like Facebook, TikTok, Snapchat, or maybe use Firestore or Google Sheet integration. With multiple websites in one sGTM, the number of sGTM elements will grow exponentially since you must create tags, triggers, and variables for each website. 

Eventually, you might reach the limits of the server-side GTM container. Yes, you can’t create an unlimited number of elements in an sGTM container. Google determines how heavy the sGTM container is by evaluating the size of the code and not the number of elements in sGTM. 

One of our test containers reached the limit of 85% with only 41 tags and 5 clients. When the container comes to the limit, you should either restructure the sGTM container into several sGTMs, which means using another tagging server URL. Or delete some parts of server GTM.

server gtm limit

Map multiple domains to one sGTM tagging serverCopy link to this section

The key feature of server-side tagging is setting first-party cookies. To do so, it’s necessary to configure a custom domain for a tagging server URL. Custom domain should be located within your main site domain hierarchy. When using sGTM for one site, it’s easy to determine a custom domain, just use top-level domain +1.

Here I want to cover two scenarios for using one sGTM for multiple domains. 

1. Different domainsCopy link to this section

When mapping websites with completely different domains into one sGTM endpoint, it's necessary to create a custom domain for each site individually. Later in this article, I will show you how to configure tagging server, server and web GTMs for multi-domain containers with different domains. 

2. Sharing the same domainCopy link to this section

When websites share the same domain (example.com and blog.example.com), tagging server domain should be configured on the top-level domain + 1 (eTLD+1) of the given domain or URL. 

This means that for websites example.com and blog.example.com tagging server should look like ss.example.com. In this case, both domains will have access to set first-party cookies. Do NOT use something like ss.blog.example.com. 

How to set up Multi-domain container on stapeCopy link to this section

Multi domains feature is available for stape Business (and higher) plan users. To enable it, open the sGTM container, click Power-Ups, and Click Config Multi-Domains. 

multidomain set up stape

Add all subdomains that you want to use for the server-side endpoint. There are no limits on the domain number. Once done, you would have to create an A record for all of the ss custom domains, similar to what you usually do for a single domain. 

map multiple domains to server gtm

Server Google Tag Manager debugger with multi-domainsCopy link to this section

The only thing that needs to be set up in the server GTM container is Server container URLs in the Admin settings. Here you will need to add all server container URLs that you’ve set up in the previous step. To do so open admin -> Container Settings -> add URL under Server container URLs.

configure sGTM tagging server URL

Adding server container URL affects the sGTM debug URL. To select the tagging URL you want to use for debugging, click the selector near the preview button.

preview mode sGTM multidomain

You will see the custom domain list you’ve added in the container settings. Select one from the list of the domains. 

select deggger URL sGTM

Once done, click preview and check if the preview URL uses the correct custom domain, the one that you’ve selected in the previous step. 

Web GTM with multiple tagging server URLsCopy link to this section

We approach necessary changes in web GTM with a multidomain tagging server using the lookup table variable. In the web GTM, you need to send, for example, UA data to the pacific tagging server URL. The best way to set it up is by using the Lookup Table variable. This lookup variable should check the page hostname, and depending on that set tagging the server URL.

lookup variable tagging server

ConclusionCopy link to this section

Hope this blog post shed more light on configuring a server GTM container for multiple tagging servers. This is a handy feature when using different domains for website localization, brands, products, landing pages, etc. 

While setting up server-side Google Tag Manager is getting more popular, it can be a little daunting for those who have never done it before. If you need help getting started, our team of experts are more than happy to assist you. Contact us today, and we’ll get your tracking set up in no time!

Need help with setting up server-side tagging?

All it takes is a few simple questions. Click Get A Quote, fill-up the form, and we will send you a quote.

Get a Quote
Tagged with:sGTM tag

Relevant posts

Aug 20, 2021

Third-party cookies are about to expire. Will server-side tracking help?

By the end of 2024, Chrome and Chrome-based browsers will be done with third-party cookies. Safari and Firefox already implemented Intelligent Tracking Algorithms that can block trackers. That leads to the next point: digital advertising methods that rely on third-party cookies to target consumers might become ineffective or even stop working altogether. This change in how advertisers track users will hurt many publishers and ad networks that rely on these third-party companies to display ads and collect data from site visitors to understand their audience. In this blog post, I will explain what a third-party cookie is, why it matters, and how server-side tracking can help businesses transit to the world without third-party cookies.

Oct 6, 2020

How to add a custom domain to the Google Tag Manager Server container

In this article, I will describe how to set up a custom subdomain within your Google Tag Manager server container. The main advantage of a custom subdomain inside the Google Tag Manager Server container is that it helps to bypass Intelligent Tracking Preventions, AdBlockers and increases cookie lifetime for users browsing in Safari. Pixels will be loaded from your subdomain and run as the first-party.

Mar 8, 2022

Extend cookie lifetime using server-side Google Tag Manager

Learn how to use server Google Tag Manager to extend cookie lifetime. This will help you with tracking restrictions that affect 3rd party cookies.

Host your GTM server at Staperight now!