How do you set up tracking for multiple domains on the same container?
If you manage multiple websites, you can choose to use a single Google Tag Manager setup for all of them.
If you manage multiple websites, you can choose to use a single Google Tag Manager setup for all of them. This article explains how to configure server-side tagging for multiple domains within the same GTM container.
Possible scenarios

There are four scenarios in which you work with multiple domains:
Multiple websites, each with their own GTM web and GTM server container Each website has its own GTM web container, which sends data to its own server container. This is the most common server-side tagging setup. Example: You manage shop-a.com, shop-b.com and shop-c.com. Each website has its own GTM web container and its own server-side tagging subscription.
Multiple websites on the same GTM web container You use one GTM web container for multiple websites. The tracking code is the same on every site, but you want to distinguish between the domains in your tags and configuration. Example: You manage shop-a.com, shop-b.com and shop-c.com and want to use the same GTM web container for all three.
Multiple domains on the same GTM server container You have multiple websites, each with its own GTM web container, but all of them send data to the same server container. Example: Several clients each have their own GTM web container, but they all use the same server-side tagging subscription.
Multiple domains on the same GTM web and GTM server container You use one GTM web container for multiple websites, and all of them send data to the same server container. Example: You manage shop-a.com, shop-b.com and shop-c.com, use the same GTM web container for all three, and all three share the same server-side tagging subscription.
In scenarios 2, 3 and 4, your configuration needs to be domain-specific, so the right data is sent to the right destinations.
Configuration in the GTM web container
If multiple domains use the same GTM web container, you need a variable that detects the current domain and returns the right value based on it.
Replace constant values with a Lookup Table or RegEx Table variable
Depending on your situation, you use either a Lookup Table or a RegEx Table variable to split your constant values. Values you’ll typically want to split include your GA4 Measurement ID, your server container URL and your Meta Pixel ID.
To create this variable:
Open your GTM web container and go to Variables.
Under User-Defined Variables, click New.
As Variable Configuration, choose Lookup Table or RegEx Table:
Choose Lookup Table when the input is always exactly the same. For example, use the Page Hostname variable when the domains differ by domain name: yourdomain.nl and yourdomain.com.
Choose RegEx Table when the input isn’t always exactly the same. For example, use the Page URL variable when the domains are distinguished by the path after the slash: yourdomain.com/nl and yourdomain.com/de.
As Input Variable, select the variable you want to base the distinction on.
Click Add Row to set a specific Output for each Input (Lookup Table) or Pattern (RegEx Table).
Examples of splitting your GA4 Measurement ID:


Configuration in the GTM server container
If multiple domains send data to the same GTM server container, the server container needs to be able to tell these domains apart.
Replace constant values with a RegEx Table variable
To distinguish between the domains of incoming requests, use a RegEx Table variable. Values you’ll typically want to split include your GA4 Measurement ID, your Google Ads Conversion ID, and your Meta Pixel ID and Conversions API access token.
To create this variable:
Open your GTM server container and go to Variables.
Under User-Defined Variables, click New.
As Variable Configuration, choose Event Data.
Enter page_location as the Key Path and save the variable.

Create another new variable and choose RegEx Table as Variable Configuration.
As Input Variable, select the page_location variable you just created. The page_location in the event data contains the URL of the page on which the event was created and sent, so you can use it to tell the domains apart.
Click Add Row to set a specific Output for each Pattern.

Last updated
Was this helpful?

