Google Analytics Hostname Filter

Google Analytics Hostname Filter

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 collected from particular domains, helping you keep unwanted data out of your reports.

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 that's sent data to your property. For example, if someone visits your website, you'll see something like 'yourwebsite.com' as the hostname in your reports. This lets you identify where the data came from.

A hostname filter is a new type of data filter. At the moment, it lets you exclude events based on their hostname. So if data arrives in your property from a domain you don't trust, you can stop it from appearing in your reports.

It looks like Google may expand this feature with an option to also include hostnames instead of only excluding them. I haven't seen this released yet, but it's something to look out for.

Hostname filter in Google Analytics before being configured

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 by only firing your tag when the hostname matched your domain, or to build report comparisons that excluded the unwanted hostnames. Both approaches 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 at the moment 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.

  1. Navigate to 'Admin', then under 'Data collection and modification', select 'Data filters'.
  2. Click 'Create filter' and choose the 'Hostname' filter type.
  3. Give your filter a clear name, like 'Exclude Hostname'.
  4. Enter the hostname (or hostnames) you want to filter.
  5. Choose your filter state. I'd suggest starting with 'Testing' – more on this below.
  6. Save your filter.
Hostname filter configured for spamsite.com in Google Analytics

Once active, any events collected that match the hostname (or hostnames) you've chosen to exclude won't appear in your reports.

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.

Double-check your settings before activating the filter. It's much easier to confirm your valid 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, helping you prevent data from unwanted domains from appearing 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, enter the hostname you want to filter, and save the filter.

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 event data sent to your property from a domain that isn't yours. Excluding the unwanted hostname helps keep your reports accurate.

Conclusion

Hostname filters make it easier to reduce unwanted data in your reports. Currently, the feature supports excluding hostnames, but it looks like Google may add more options soon, including the ability to include specific hostnames. Once this is available, it will make hostname filtering more flexible, allowing you to only accept data from the domains you specify.

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.