Share
Contents
If you transited from Universal Analytics to Google Analytics 4, you are aware of all the filters Universal Analytics had, and you, most likely, want to replicate them in GA4. Although many blogs are written to teach you how to set up GA4 filters, including internal and developer traffic filters, there is not much information about a hostname filter in GA4.
Therefore, l dedicated this blog post to keeping you updated about the latest GA4 news on a hostname filter. It means that I will update this article whenever a new GA4 update takes place.
Let’s delve into it.
Is it possible to set up a hostname filter in GA4 the same way as in Universal Analytics?
The short answer is no. There is no possibility nowadays to set up a hostname filter using a GA4 interface. You can do it with Google Tag Manager. However, before doing something with that, you should check if there is a need.
To see how many hostnames send the data into your GA4 account, please follow one of the following solutions:
Solution A:
- Login to the GA4 account
- Click on the Search bar and type “hostname”
- Select the report “Top Hostname by Users”

Solution B:
- Login to the GA4 account
- Go to Explorations and create a new one
- Import dimension “Hostname” and “Event count” metrics to the report
- Add the dimension and metrics to the report

You will see the number of users vs hostname report. If you see only one and it’s the right one, you likely don’t need to look after that. (similar to what I have on my screenshot) Just leave it for the time when Google release the hostname filter in GA4.
Otherwise, if you have many hostnames and some of them are not relevant to your business, you can open a Google Tag Manager and set it up using the instructions provided in the next section of this article.
Note: Please remember that filtering traffic in Google Tag Manager is not the same as filtering traffic in Google Analytics. If someone is sending data from their website with your GA4 measurement id, your GTM tag won’t be able to filter it.
How to set up a hostname filter using Google Tag Manager for Google Analytics 4?
Time needed: 15 minutes
As I mentioned above, you need to use Google Tag Manager and take the following steps:
- Create a new variable
1. Name “My Hostname RegEx Table”
2. Variable Type – RegEx Table
3. Input Variable – Page Hostname
4. Pattern – your domain (for instance, www.vakulski-group.com)
5. Output – your GA4-measurement Id (for instance, G-KF9LRYZ10K) - Update your main GA4 tag to use the variable you created (after that, all your GA4 event tags will use that RegEx table)
- Publish a GTM Container
If you have more than one domain to include, add more patterns in the RegEx table variable.
How to apply a GA4 hostname filter in GA4 reports?
According to the note I wrote above, the Google Tag Manager setup has its own limitations. If you find yourself that you set up a GA4 hostname filter using GTM and GA4 still shows some hostnames that are not relevant, most likely, it’s something that you can’t control.
Therefore, I can recommend only one solution to that – filter your GA4 data using a hostname dimension. It is suitable for all reports in Google Analytics 4 apart from the Real-Time Report.
For instance,
You can apply a filter in the GA4 Explorations report; just select dimension “Hostname” contains “your domain”. After that, you analyse the traffic of only the hostname you are interested in.

In all other reports, click on the audience, add a new condition, select “hostname” and select your hostname. After that, you can apply the filter.

Final Thought
Unlikely Universal Analytics, Google Analytics 4 doesn’t have a native hostname filter. You can use Google Tag Manager to create a similar filter, but it has disadvantages. Otherwise, when analysing data, you can apply the hostname filter for GA4 reports.
If you find this article helpful or know another way to filter GA4 data by hostname, please let me know by leaving a comment below.
How do I add a hostname filter in Google Analytics 4?
At this moment, there is only one solution for that. You can use Google Tag Manager and set up a RegEx table variable to trigger the correct GA4 measurement id for the relevant hostname.
Unfortunately, there is no hostname filter in Google Analytics 4. Google can add it in the future, but for right now, there are only a few ways to address it using Google Tag Manager.
You Might Also Like

Written By
Ihar Vakulski
With over 8 years of experience working with SaaS, iGaming, and eCommerce companies, Ihar shares expert insights on building and scaling businesses for sustainable growth and success.
KEEP LEARNING
There are many blog posts about GA4 filters and, more specifically, about the importance of the internal traffic filter in Google Analytics 4. However, only…
Suppose you have just started a website and installed Google Analytics 4 or running a successful business and migrated from Universal Analytics to Google Analytics…
Leave a Comment
Your email address will not be published. Required fields are marked *
Stay Updated About Every New GA4 Feature
Subscribe to this newsletter to learn more about new Google Analytics 4 features and adjustments.
No SPAM and only relevant content guaranteed!
3 Replies to “How to use a hostname filter in GA4”
I was baffled to see the random spam bot traffic to non-existing pages, and this article clarified the situation : ) The instructions to set up a filter were helpful!
Thank you very much for the feedback! It matters a lot to me.
Thank you for this. Now that Google is recommending using the same data stream for any sites on which you want cross-domain tracking, this ability to separate hostnames is critical!