Hostname Filter in Google Analytics 4 (GA4)
Benjamin Mangold
Google has added a new way to keep unwanted data out of your reports. As of June 11, 2026, you can create a hostname filter in Google Analytics. It lets you exclude events that don't come from a domain you've approved, so your reports only reflect the websites you actually care about.
If you've ever opened your reports and noticed traffic from a domain you don't recognize, this update is for you. Let's take a closer look at what hostname filters are, why they matter, and how to set one up.
What is a hostname filter?
A hostname is the domain your data is collected from – for example, 'yourwebsite.com'. Every event sent to Google Analytics includes a hostname, which tells you the website the data came from.
A hostname filter is a new type of data filter. It lets you exclude events based on their hostname. So if data arrives into your property from a domain you haven't approved, you can stop it from appearing in your reports. This means anything that doesn't come from your real website won't distract from your analysis.

It joins the two data filters that were already available – the internal traffic filter and the developer traffic filter. You'll find all of them in the same place inside your Google Analytics property.
Why this matters
You might be wondering why you'd ever see data from a domain that isn't yours. Here's how this happens.
Your Google Analytics measurement ID is included in the tracking code on your website, and that code is visible to anyone who looks at your page. From time to time, spammers copy a measurement ID and send fake events directly to Google Analytics, without ever visiting your website. This is often called ghost spam or referral spam.
Because these events never touched your website, they usually carry a hostname that isn't yours. It might be the spammer's own domain, or it might show up as '(not set)'. Either way, it pollutes your reports and can quietly skew your metrics.
In the past, the common fix was to handle this in Google Tag Manager (only firing your tag when the hostname matched your domain) or to build report comparisons that excluded the bad hostnames. Both work, but they take effort. A hostname filter gives you a cleaner, built-in option.
"It's great to see the hostname filter, but it's a bit disappointing it's exclude-only with no regex matching. I'd like more flexibility in how we filter in Google Analytics."
How to create a hostname filter
Here's how to set one up. Keep in mind you'll need Editor or Administrator access to your Google Analytics property.
- Navigate to 'Admin', then under 'Data collection and modification', select 'Data filters'.
- Click 'Create filter' and choose the 'Hostname' filter type.
- Give your filter a clear name, like 'Exclude Hostname'.
- Set the filter operation and enter the hostname (or hostnames) you want to act on.
- Choose your filter state. I'd suggest starting with 'Testing' (more on this below).
- Save your filter.

Once it's active, any events from a hostname that doesn't match your approved domains won't be collected.
Start with the testing state
Before you switch your filter to 'Active', I'd strongly recommend leaving it in the 'Testing' state for a few days.
This is important because data filters are not retroactive, and once a filter is active, the data it excludes is gone for good. There's no undo button.
In the testing state, Google Analytics marks the events that would be excluded without actually removing them. You can then check the 'Test data filter name' dimension in your reports to confirm the filter is catching what you expect, and nothing you don't. Once you're confident, switch it to 'Active'.
Tip: Give your filter at least 24 to 48 hours in the testing state before activating it. This gives you enough data to be sure you're not excluding real visitors.
A common mistake to avoid
The biggest risk with hostname filters is accidentally excluding traffic you actually want.
If you run a cross-domain setup, use subdomains, or send data from more than one website into the same property, you'll have several valid hostnames. Before you activate a filter, take a moment to list every legitimate domain that sends data to your property. You can find them using the 'Hostname' dimension in your reports.
Do a quick double-check here. It's much easier to confirm your approved hostnames up front than to discover later that you've been dropping real data.
Frequently asked questions
What is a hostname filter in Google Analytics 4?
It's a data filter that excludes events based on their hostname, so data from domains you haven't approved isn't collected in your reports.
How do I create a hostname filter?
Navigate to 'Admin', then under 'Data collection and modification', select 'Data filters'. Click 'Create filter', choose the 'Hostname' type, set your rule, and save.
Are hostname filters retroactive?
No. Data filters only affect data going forward. They won't clean up historical data that's already in your reports.
Why would I use a hostname filter?
The most common reason is to block ghost spam, which is fake events sent to your property from a domain that isn't yours, so your reports stay accurate.
Conclusion
Hostname filters are a small addition, but they solve a problem that used to take a workaround to fix. By excluding data from domains you haven't approved, you keep your reports focused on the websites that actually matter to you.
If you haven't reviewed your hostnames recently, now's a good time. Open the 'Hostname' dimension in your reports, see which domains are sending data, and you'll know straight away whether a hostname filter is worth setting up.