Managing multiple domains or environments the smart way
If you’re working with multiple websites, environments, or brands, you’ve probably faced this:
👉 Different GA4 properties
👉 Different Measurement IDs
👉 Same tracking logic
So… what do most people do?
❌ Duplicate tags
❌ Create multiple configurations
❌ Turn GTM into a mess
But there’s a smarter way to handle this.
The problem with duplicating GA4 tags
Let’s say you’re using Google Tag Manager with:
- domainA.com
- domainB.com
Each one has its own property in Google Analytics 4.
The “traditional” approach is:
- Create one GA4 tag per domain
- Duplicate events
- Manage everything separately
👉 This leads to:
- Errors
- Inconsistencies
- Hard maintenance
The solution: Use a Lookup Table in GTM
Instead of duplicating tags, you can use a Lookup Table variable.
👉 This allows you to dynamically assign the correct GA4 Measurement ID based on a condition.
One tag. Multiple destinations. Clean setup.
⚙️ How it works (simple concept)
You define a rule like this:
- If Hostname =
domainA.com→ use GA4 ID A - If Hostname =
domainB.com→ use GA4 ID B
Then, GTM automatically sends data to the correct property.
Step-by-step implementation
Step 1 — Create a Lookup Table Variable
Go to:
GTM → Variables → New → Lookup Table
Configure it like this:
- Input Variable:
{{Page Hostname}}
| Input | Output |
|---|---|
| domainA.com | G-XXXXXXXA |
| domainB.com | G-XXXXXXXB |
👉 Each output is a different GA4 Measurement ID
Step 2 — Use the variable in your GA4 tag
Now go to your GA4 Configuration Tag (or Event Tag):
In the field:
👉 Measurement ID
Instead of hardcoding:
G-XXXXXXX
Use your variable:
{{Lookup - GA4 Measurement ID}}
👉 That’s it.
Now the same tag adapts automatically.
When should you use this approach?
This is perfect for:
✅ Multi-domain setups
- Multiple websites under one GTM container
✅ Environments
- Dev / Staging / Production
✅ Multi-brand tracking
- Different GA4 properties per brand
Why this is better (real advantages)
1. Cleaner container
No duplicated tags → easier to manage
2. Less room for errors
One logic → applied everywhere
3. Easier scaling
Add a new domain?
👉 Just update the Lookup Table
4. More professional implementation
This is the kind of setup that shows:
- structure
- scalability
- best practices
👉 Exactly what recruiters look for in a tracking specialist
Common mistake to avoid
Don’t do this:
❌ One tag per domain
❌ One trigger per environment
❌ Copy-paste chaos
👉 This becomes unmaintainable very fast.
Pro tip: Combine with environments
You can take this further by combining:
- Hostname
- Environment variable
👉 Example:
- dev.domain.com → test GA4 property
- domain.com → production property
Final insight
Anyone can make tracking work.
Not everyone can make it scalable.
Good implementations don’t just work — they stay clean as they grow.
About me
I focus on building scalable and reliable tracking systems using GA4 and GTM—ensuring clean data, efficient setups, and long-term maintainability.
If you’re looking for someone who can simplify complex tracking setups…
let’s connect.
