Jump to content
KUHM

Exclude a Domain in Google Analytics: Hostname Filter and Unwanted Referrals

Posted on - Updated

Exclude a Domain in Google Analytics: Hostname Filter and Unwanted Referrals

To exclude a domain from Google Analytics today, the method goes through GA4: a "Web hostname traffic" data filter removes visits recorded on a specific domain, and the "List unwanted referrals" setting stops a domain from appearing as a traffic source.

I often get requests from clients who do not want a certain domain to appear in their Google Analytics statistics: a staging site sending its visits to the same property, a copy of the site hosted elsewhere, a payment provider slipping in among the sources. Do you also want to filter a domain out of your statistics? The procedure has changed since the first version of this article.

Why the old "Filter Manager" is gone

The "Filter Manager" once described here belonged to Universal Analytics, the former version of the tool. Google has shut down Universal Analytics: its standard properties no longer process hits, and the predefined "Exclude + Traffic from domains" filter no longer exists. A Google Analytics 4 property is set up elsewhere, in the Admin screen, with two distinct mechanisms depending on what you want to remove.

  • The domain that receives the visits (a staging site, a mirror site, a test site): exclude it with a data filter on the hostname.
  • The domain that sends the visits (a payment gateway, an authentication tool): declare it as an unwanted referral.

Mixing up the two leads to a filter that does nothing: ignoring a referral does not remove any visit, and a hostname filter does not change traffic sources.

Exclude a hostname with a GA4 data filter

The "Web hostname traffic" data filter removes from the property the events recorded on a chosen domain. It requires the Editor role on the property. The process stays short:

  1. Open Admin, then, under "Data collection and modification", the "Data filters" section.
  2. Click "Create filter" and choose "Web hostname traffic".
  3. Give the filter a name that is unique within the property (I always recommend a name that includes the targeted domain, so you can find your way when filters pile up).
  4. Choose the "Exclude" operation.
  5. Select the match type: "exactly matches", "begins with", "ends with" or "contains".
  6. Enter the hostname to exclude, for example preprod.my-site.com.
  7. Leave the filter state on "Testing", then click "Create".

The opposite operation, "Include only", is used when a single domain should feed the property: everything coming from elsewhere, copies and bots included, then disappears from the reports.

Test the filter before activating it

A GA4 data filter in "Testing" state removes nothing: Google Analytics tags the affected events with the "Test data filter name" dimension. After 24 to 36 hours, a free-form exploration that crosses this dimension with the event name shows what the filter would remove. If only the right hostnames appear, go back to Data filters, open the filter and set its state to "Active".

An active filter is permanent

Switching to the active state commits the property: filtered data is never processed, neither in Google Analytics nor in BigQuery, and the filter does not affect historical data. To hide a domain in a report without losing the information, a report filter or a comparison is enough.

Ignore a referring domain

A domain that sends your visitors back to your site, such as a bank payment page, creates a new traffic source and breaks conversion attribution. GA4 handles it in the data stream settings:

  1. In Admin, open "Data streams", then your web stream.
  2. Click "Configure tag settings", at the bottom of the screen.
  3. Show all settings and choose "List unwanted referrals".
  4. Choose a match type, enter the domain, add one condition per additional domain, then save.

Conditions are combined with an "OR" logic: a single matching domain is enough for the referral to be ignored.

Exclude a Google Analytics domain without aiming at the wrong target

Before creating a filter, I always check the exact hostname in a report broken down by hostname: a domain with or without www, or a subdomain, does not necessarily match the planned rule. On a site moved to HTTPS, the effect of SSL and "not provided" in Google Analytics already blurs the sources enough without adding fake visits. Once the filter is active, keep a record of its creation date: it explains the break in the curves when you compare two periods. As for visibility, a staging site open to robots is also a problem in search results; the sitemap submitted to Google should list only the addresses of the production domain.

The steps may seem long on paper, but in practice creating a filter takes a few minutes; it is the check in "Testing" state that demands patience.

About the author

Cyril KUHM

Cyril KUHM

Head of MKH, a web agency near Strasbourg, and SEO consultant since 2007. On this blog I share free, hands-on advice to help your site rank better on Google.

Get in touch

Related posts

↑