In my previous two blogs I explained how to identify spam traffic in Google Analytics data and then how to remove the false hits from historical data using a segment view. In this final part I’m going to cover how I set up a filter to prevent it being recorded in the first place.
Effectively, I needed to take the two filters I had applied to the segment view and turn them into an actual filtered view.
Before starting I had two things to consider:
- It’s considered best practice to set up the filter as a second view on an Analytics property (leaving the default unfiltered ‘All website data’ to do it’s own thing).
- Ideally, the best time to do this is when first setting up Analytics on a new website so both views have been collecting data for the same amount of time.
This way it’s easy to compare the two views to check the filters are working correctly by comparing the collected data.
Creating a New Filtered View in Google Analytics
To begin, I went to the Admin tab and selected the account and property of the site I wanted to filter.
I then clicked on the View dropdown and selected Create New View.
I named the new view ‘Remove Bot Spam’, set the timezone and then clicked Create View.
I then returned to the main Admin screen and clicked on the Filters option under the view I just created.
As I established when setting up the Segment view, I needed to apply two different filters to block out both the Ghost Referrals and Crawler Bot types of spam hits.
Check out Part 1 of my blog for more information on identifying types of spam on Google Analytics.
Creating a Valid Hostname Filter to Block Out Ghost Referral Hits
I’d previously figured out that Ghost Referral hits all have the common attribute that their Hostname attribute (ie. where the hit was tracked) does not match up to that of my website as the hit did not actually take place on my website (hence the Ghost name)! Presumably, someone had harvested my Analytics tracking code and stuck it somewhere in the deep corners of the internet.
Therefore, the most effective way of blocking these types of fake hits was to set up a new filter to only include traffic with a Hostname value of my website (in my case pauljardine.co.uk) as this is the only place I want to measure traffic.
Note that if you are using your Analytics code on any other website (such as on Paypal if you have a checkout there) you’ll also need to include that in your filter pattern in regex format.
Creating a Filter to Block Bot Crawler Hits
The second filter I needed to create was to block out all the Crawler Bot traffic. As these bots actually did visit my website their Hostname attribute was set to PaulJardine.co.uk, however, by looking at the Referrals data in the Acquisition tab of my original unfiltered data they were clearly identifiable as spam by where they have come from.
I had already created a list of these spam referral sites and converted them into regex format when I first set up my segment view so now I needed to apply this to my new view.
Read my blog on setting up a Filtered Segment View on Google Analytics for more information on how I put the list of spam sites together.
My second filter was set to exclude any hits with a referral value of my regex list. Like this…
Most likely this filter will need updating over time as new Bot Crawlers start hitting my site.
The image above was taken a week later, revealing that over half of my site traffic recorded by the unfiltered view as spam!! My filtered view therefore gives a far more accurate session duration and bounce rate (both of which where affected by the Bot Crawlers leaving the site immediately after arriving). This makes the data actually useful for making informed design decisions for future updates.
I’ll be monitoring my new filters over time and comparing them against the original unfiltered view to compare how they are performing. As I mentioned earlier, it’s likely that the second filter will need updating so I’ll be keeping a close eye on my referral traffic in particularly.
If you are interested in learning more about removing Google Analytics spam I highly recommend reading the Definitive Guide to Removing Referral Spam on Analytics Edge.
Get helpful advice and articles into your inbox once per month with the PJWD newsletter.