View filters allow you to limit traffic data that is included in a view in Google Analytics. Using a filter, we can exclude referrer spam being added to Google Analytics from sources like Darodar by creating a filter that only includes visits with a hostname that matches our domain name. Since most referrer spam pings Google Analytics directly, using your tracking ID without knowledge of your domain name, that spam will automatically get rejected from your reports.
(More about what Darodar is and what it does.)
A few important notes before we start…
- Filters only work for future visits to your website and will not change past data or reports.
- Filters will permanently modify the traffic data collected while the filter is active, so it’s important to apply filters to Views other than All Web Site Data.
- If you create a new view to apply filters to, past data will not be included in the new view.
- Although this is a very effective solution today, that may change in the future as spammers change their techniques.
Creating the Filter
- Log in to Google Analytics.
- Click the Admin link at the top of the page.
- Choose the Account, Property, and View you want to add the filter to. Don’t apply the filter to the All Web Site Data view–you want a clean copy of all the traffic to your website. If you need to add a new filter, click the View drop-down menu (that shows All Web Site Data by default) and click Create new view to add a new view for your filter.
- Click Filters under the View column.
- Click the New Filter button.
- Configure a new Predefined Filter Type that only includes traffic with a Hostname that matches your website. See the screenshot below…
If you have a basic website, you can enter your domain name in the Hostname field. For example, entering tythewebguy.com will only include visits where the host name contains tythewebguy.com–with and without the www in front. If you have more than one domain name, have sub-domains, or use Google Analytics to track your traffic on other websites, you can create a custom filter that does the same thing, but includes all the possible domains that should be included.
Important note: Be sure to update your filter if you ever change domain names, add sub-domains, or add your tracking code to another website and want that traffic included in your reports.
Learn more about view filters in Google Analytics.