One of the biggest benefits of using server-side tagging is first party context Between the site sending the data and the server-side tagging endpoint itself.
This leads to many Benefits include improved control of data streamthe possibility to set cookies spread beyond Limitations of ITPsand relieved stress on what is likely already heavily overloaded Content security policy.
This article shows how to map multiple custom domains to your Google Cloud project application. It also shows how to configure the container to support previews for all these different domains.
X
shimmer newsletter
Subscribe to our Simmer newsletter to receive the latest news and content from Simo Ahava right in your email inbox!
Tip 124: Map multiple domains to server-side tagging endpoints
because the domain exists first party context I need to share these two domains with other domains. Top Private Domain Names.
took www.simoahava.com
When sgtm.simoahava.com
The best domain name I can personally control is simoahava.com
(because you can’t buy .com
). Since this is shared by both domains, they are considered within. first party context.
So when I created the server-side container, I configured it to use sgtm.simoahava.com
Requests sent after that as the domain name www.simoahava.com
(or any other subdomain) is considered a first party request.
But what if you want to use the same container to serve requests? www.gtmtools.com
?
if you send me a request www.gtmtools.com
To sgtm.simoahava.com
the top private domain names are No same (simoahava.com
versus. gtmtools.com
).request right The server container can do something with it, but it’s a 3rd party request and has a big impact on how e.g. cookies are processed.
Solution?
Map additional custom domains to endpoints
By going through Steps to map a custom domain Alsoand adding new domain mappings (using A/AAAA DNS records), the server-side tagging endpoint can be configured to respond from multiple domains.
In the screenshot above I have mapped three Different domains to server-side endpoints.This means without further configurationyou can send requests to any of these three domains and the server-side endpoint will handle them.
Configure a container and enter preview mode
in Google Tag Manager servers container settings (under admin), you need to add these domains to Server container URL list:
Once your domain is on this list, you can enter: preview mode for that domain.
To enter preview mode, return to the normal workspace view of GTM and preview button.
In the overlay that appears, click the domain name for which you want to enable preview mode.
After doing this preview Clicking the button opens preview mode for the domain currently selected in the domain selector.
[プレビュー]Click the button and double check that it opens with the correct origin to make sure everything works.
Overview
Mapping multiple custom domains can be useful, for example, if the virtually identical site is served by different TLDs (such as country sites) or by completely different sites (such as branded sites). very useful in case
The underlying server infrastructure remains the same. Mapping a custom domain does not imply that additional servers will be added to your setup or anything like that. These are just additional entrances to the server-side tagging endpoint.
Naturally, each additional site you set up to collect data to your server-side tagging endpoint puts additional stress on the instances running on your stack and on your monthly bill. client When tag For example, if the response is designed to set cookies (the domain of the cookie must match the domain of the requester).
But the crux of the problem is this: it’s Possible Maps multiple custom domains to a single server-side tagging endpoint, so in practice pretty easy to do so!
Have you ever had to map multiple domains to a server-side tagging endpoint? If so, what experiences have you had in doing so? Let us know in the comments!