Removing Referral Spam From Google Analytics

Last Updated: 22nd June 2017 (see the end of the article for details)

Are you wanting to know how to block referral traffic in Google Analytics? Almost everyone who uses Google Analytics will come across spam traffic in their statistics in one form or another. The most popular form of spam traffic is referral spam in Google Analytics. In this article, I will show you the process of removing referral spam from Google Analytics.

Removing Referral Spam From Google Analytics

What Is Referral Spam In Google Analytics?

Referral spam is fake traffic that can show up in Google Analytics as a referral visit, a search term or a direct visit. In the majority of cases, these are not actually visits and can, therefore, mess up your website analytics data by making it appear that you have had a lot more visits than you have actually had. This is extremely frustrating to anyone who is trying to measure the success of their online marketing efforts, as it is important to get a true picture of how many visits you are getting and where those visits are coming from.

The below screenshot shows just how much of an impact referral spam in Google Analytics can have. The top table shows a list of external websites (source) that have sent referral visits to our website and the bottom table shows a list of our landing pages where the visits occurred. I have highlighted all the spam visits in red and if you look closely, it is easy to see why.

What Is Referral Spam In Google Analytics

In the top table, I know that our website does not have backlinks on websites such as lifehacker.com or get-free-social-traffic.com, so it cannot be possible to have traffic from these sites. If you also think about it, just the names of these websites sound spam-like. In the bottom table, I know that we don’t have landing pages on our site with URLs such as /?from=http://www.traffic2cash.xyz/ or /www1.free-share-buttons.top, so it cannot be possible to have traffic to pages that don’t exist. You can also see that for most of these visits the average time on page is 00:00:00 which if you think about it, isn’t even possible.

Why Is Referral Spam Traffic There?

It is important to remember that referral spam in Google Analytics rarely ever occurs, so if you look at your server logs, for example, those visits would probably not show up. They are simply fake numbers that spammers have injected into the analytics software to make it look like the traffic occurred. But why would someone bother to go to all this effort? Well, the reasons are actually quite clever.

Spammers will typically want to promote a website for one malicious reason or another and they know that Google Analytics is the most popular form of web analytics software being used. By looking at the source code of any site, it is easy to see if a website has Google Analytics installed and typically anyone who uses it will be checking it on a regular basis and closely studying the data it tracks. By changing the data within Google Analytics profiles to make it look like visits have occurred from the websites they wish to promote, they know there is a good chance that people will see those sites and hopefully pay a visit when scrutinising the data.

The types of spammers that do this can vary, along with their reasons for doing it. Some may wish to simply promote their own sites or it has even been known to be a tactic used by some shady SEO companies who use black-hat methods to acquire traffic for their clients. These companies make promises to their clients by guaranteeing them a certain amount of visits – they don’t care where these visits have come from or the fact that they are low-quality visits that are highly unlikely to convert. For them, as long as they get the visits, they have done their job.

How To Block Referral Traffic In Google Analytics

For those of us that invest both time and money into marketing our websites, referral spam in Google Analytics is a real pain, as we never get a true representation of how our sites are performing as the legitimate traffic ends up being masked. So why is Google not doing something about it, I hear you ask? Well, the truth is, they are. But, as we know, spammers are always one step ahead so it is a continuous battle that seems never-ending.

When it comes to removing referral spam from Google Analytics, there are methods to block the offending URLs through your websites .htaccess file, but this does not always work due to the fact that most of the referral spam in Google Analytics does not actually visit your site and therefore does not go through your server. There is typically two types of referral spam; the first is Crawler Spam which crawls your website like a search engine does, and the second is Ghost Spam which is where they bypass your site completely and just manipulate your website analytics data. Your .htaccess file can help to block Crawler Spam but not Ghost Spam when it comes to removing referral spam from Google Analytics, and Ghost Spam is a lot more common.

As there is no way to stop Ghost Spam, as you can’t officially stop something that never really happened in the first place, you need to filter the ghost traffic out which you can do using the built-in filters within Google Analytics. Below I have listed the various filters that we use, when removing referral spam from Google Analytics, both on our own site and our clients, along with how you can apply these successfully to your own Google Analytics account:

Step 1: Make A Filtered View

When you want to know how to block referral traffic in Google Analytics, the first step to take is to create a new view within your Google Analytics profile to apply the filters to. Although you can apply the filters to the default view, I would not advise doing this as it is important to leave this for raw, untouched, data. This way, you can always switch back if you needed to.

Log in to your Google Analytics account and go to the admin screen. Under ‘View’ click the dropdown and select ‘Create new view’. Give the view a name such as ‘Filtered View’, complete the rest of the information on-screen and click ‘Create View’.

How To Block Referral Traffic In Google Analytics

Step 2: Apply Bot Filtering

Google Analytics comes with a built-in Bot Filter, which will exclude all hits from known bots and spiders. Although I find this built-in feature pretty basic and not overly effective when it comes to removing the majority of spam traffic, it is still the best place to start.

From the admin screen, under ‘View’ click ‘View Settings’. On this screen, make sure the checkbox is selected next to ‘Bot Filtering’.

Step 3: Filter Hostnames

Hostnames are basically the opposite of source. The source is the website where the visitor has come from (i.e. Facebook, Twitter, Google, etc), the hostname is the website where the visitor arrives (i.e. your own website). Your main hostname will be your website domain but there could be others, depending upon how your site is setup. By filtering out all invalid hostnames, we can remove all ghost spam visits from your data.

To find all of your valid hostnames, you need to look at the Network report that you can find by going to ‘Audience – Technology – Network’. On this screen, click the little tab titled ‘Hostname’ which is just above the table. From the list of hostnames in the table, you should be able to recognise those that are your own and those that are spam (make sure you select the widest date range possible to get the most amount of data). As well as your domain name, you may have hostnames for things like your email marketing (MailChimp, for example, will have a hostname that looks something like yourname.us13.list-manage.com). Go through the list and write down all the hostnames you recognise – anything else, including (not set) will be spam, no matter how much they look like genuine websites.

Filtering Hostnames In Google Analytics

Now, go to the admin screen and click ‘Filters’ under the ‘View’ menu. Click the ‘Add Filter’ button to add a new filter to the current view and follow these steps:

  1. Give the filter a name in the ‘Filter Name’ box
  2. Under ‘Filter Type’, select ‘Custom’ and select the ‘Include’ radio button
  3. Under ‘Filter Field’ select ‘Hostname’ from the dropdown list
  4. In the ‘Filter Pattern’ text box, type in your valid hostnames, making sure that you separate each with a vertical line (|) without any spaces and not including any www prefix. Any dots or dashes must also have a backslash in front of it. So, the hostnames for our website may look like this: improveposition\.co\.uk|improveposition\.us13\.list\-manage\.com
  5. Once done, click the ‘Save’ button to apply the filter

Step 4: Filter Crawler Spam

We can remove crawler spam by applying a filter to hide traffic from known spam websites (source). This is a little more complex, when it comes to removing referral spam from Google Analytics, as spammers will always find a way to make the traffic appear to come from a new and different website each time. However, due to experience, we know the most common websites that spammers typically use and by filtering these out, we are guaranteed to remove almost all of the spam traffic from our website analytics reports.

At the time of writing, I have tested the four filters below which have removed 100% of crawler spam for both mine and my client websites but do check the end of this article for any recent updates on removing referral spam from Google Analytics.

Go to the admin screen and click ‘Filters’ under the ‘View’ menu. Click the ‘Add Filter’ button to add a new filter to the current view and follow these steps:

  1. Give the filter a name in the ‘Filter Name’ box
  2. Under ‘Filter Type’, select ‘Custom’ and select the ‘Exclude’ radio button
  3. Under ‘Filter Field’ select ‘Campaign Source’ from the dropdown list
  4. In the ‘Filter Pattern’ text box, copy and paste the following:
    uptime(robot|bot|check|\-alpha|\.com)|vitaly|sharebutton|semalt|ranksonic|share\-button|anticrawler|timer4web|free\-video\-tool|responsive\-test|dogsrun|fix\-website\-er|dailyrank|sitevaluation|seo\-2\-0\.|99seo|top10\-way
  5. Once done, click the ‘Save’ button to apply the filter

Now, follow the same steps again to set a second filter, but add the following as the ‘Filter Pattern’:
(videos|buttons)\-for\-your|best\-seo\-(solution|offer)|buttons\-for\-website|profit\.xyz|dbutton|keywords\-monitoring|platezhka|7makemoney|forum69|kings\-analytics|checkpagerank|pr\-cy\.ru|\-\-(production|website|sale)\.com

Now, follow the same steps again to set a third filter, but add the following as the ‘Filter Pattern’:
(express|audit|dollars|success|top1|amazon|commerce)\-seo|free\-video\-tool|datract|hacĸer|ɢoogl|slifty\.github|\-liar.ru|3\-letter\-|foxweber|free\-fbook|goodwriterssales|your\-rankings|tourcroatia|spinnerco|justkillingti|suralink|worldtraveler\.w

Finally, follow the same steps again to set a fourth filter, but add the following as the ‘Filter Pattern’:
oldfaithfultaxi|christopherlane|hollywoodweeklymagazine|losangeles\-ads

Step 5: Filter Fake Languages

Language spam is one of the newer forms of referral spam in Google Analytics, where spammers inject messages into the language HTTP header, as you can see from the below example:

How To Filter Fake Languages In Google Analytics

Go to the admin screen and click ‘Filters’ under the ‘View’ menu. Click the ‘Add Filter’ button to add a new filter to the current view and follow these steps:

  1. Give the filter a name in the ‘Filter Name’ box
  2. Under ‘Filter Type’, select ‘Custom’ and select the ‘Exclude’ radio button
  3. Under ‘Filter Field’ select ‘Language Settings’ from the dropdown list
  4. In the ‘Filter Pattern’ text box, copy and paste the following:
    \s[^\s]*\s|.{15,}|\.|,|^c$
  5. Once done, click the ‘Save’ button to apply the filter

Step 6: Segment The Current Data

The steps above will ensure that any new traffic data that Google Analytics records will now have the spam visits removed. However, the new filters will not apply to any previous traffic data that had already been recorded before the filters were created.

There is a way to apply the filter rules to previous traffic data by adding a new segment to the default, unfiltered view. To do this, go to the admin screen and click ‘Segments’ under the ‘View’ menu. Click the ‘+ New Segment’ button to add a new segment to the unfiltered view and follow these steps:

  1. Give the segment a name in the box at the top of the page
  2. Click ‘Conditions’ in the left column and make sure the first row reads: ‘Filter Sessions Include’ by selecting the correct items from the dropdowns
  3. In the second row, select ‘Hostname’ and ‘matches regex’ from the first two dropdowns
  4. In the text box, copy and paste in your hostnames from Step 3
  5. Click the ‘+ Add Filter’ button to add a second filter
  6. In the second filter box that appears, make sure the first row reads: ‘Filter Sessions Exclude’ by selecting the correct items from the dropdowns
  7. Select ‘Source’ and ‘matches regex’ from the first two dropdowns in the second row
  8. Copy and paste the following into the text box:
    (brateg|budilneg|buketeg|bezlimitko|biteg|boltalko|begalka|alfabot|arendovalka|bank\-rot|abcdefh|aptechko|bukleteg|abc)\.xyz|(magnet\-to\-torrent|torrent\-to\-magnet)\.com|(baixar|descargar)\-musica|wordpress(\-start|\-crew)|uptime(robot|bot|check|\-alpha|\.com)|vitaly|sharebutton|semalt|ranksonic|share\-button|anticrawler|timer4web|free\-video\-tool|responsive\-test|dogsrun|fix\-website\-er|dailyrank|sitevaluation|seo\-2\-0\.|99seo|top10\-way|(videos|buttons)\-for\-your|best\-seo\-(solution|offer)|buttons\-for\-website|profit\.xyz|dbutton|keywords\-monitoring|platezhka|7makemoney|forum69|kings\-analytics|checkpagerank|pr\-cy\.ru|\-\-(production|website|sale)\.com|(audit|dollars|success|top1|amazon|commerce)\-seo|free\-video\-tool|datract|hacĸer|ɢoogl|slifty\.github|\-liar.ru|3\-letter\-|rencer\.ru|oldfaithfultaxi|christopherlane|hollywoodweeklymagazine|losangeles\-ads
  9. Click the ‘Or’ button to add a second rule
  10. Select ‘Language’ and ‘matches regex’ from the first two dropdowns
  11. In the text box, copy and paste the following:
    \s[^\s]*\s|.{15,}|\.|,|^c$
  12. Click ‘Save’ to save the segment.

The end result should look something like this:

Adding Segments In Google Analytics

Now, whenever you are viewing a report and thinking about how to block referral traffic in Google Analytics, you can add this segment to the current view to filter out the spam visits on traffic data in the past. In time, the new filters will do this for you, so you won’t need to use the segment from this point onwards.

Give Your Feedback On Removing Referral Spam From Google Analytics

I hope you found this article on removing referral spam from Google Analytics helpful. The steps above is the exact process that we follow for all our own clients, so if you are already investing in one of our SEO Packages, you can rest assured that this work has already been carried out on your site. If you are not already a client of ours and would like us to implement all of the above for you, then get in touch with us so we can help.

As new spam sites are found, I will update this article with new filter patterns, so do check back regularly. Also, do leave us your comments below if you find that you are still getting referral spam in Google Analytics after implementing all of the above, so I can investigate and make any needed tweaks to these filters.

Signup To Our Newsletter

Update: 19th April 2017

In this update, we have added some additional code to the above filters, as per the following:

  • Bot traffic has recently been detected that is labelling languages with the letter ‘C’. This has now been added to the language filter above.
  • A couple of new crawlers have been found, which have now been added to the crawler filters above.

There has also been a new form of spam detected that is a mixture of crawler and ghost spam. As the spammer is using some valid referral names, you will need to add a new filter for Page Title Spam. To do this, add a new filter following the same steps as your crawler spam filters, but change ‘Campaign Source’ to ‘Page Title’ and use the following expression: google\-liar|whitehouse\.gov|life\.ru|vice\.com|vc\.ru. Remember to add a segment for this new filter if you wish to apply this to historical data.

Update: 31st May 2017

In this update, we re-built all of the above filters to make them shorter and to protect against 5 new crawlers that have been detected. This has also involved adding a 3rd Crawler Spam filter, details of which are above. This new filter has already been added to the segment code above if you wish to remove the spam from historical data as well.

Update: 22nd June 2017

In this update, we re-built all of the above filters to make them shorter and to protect against 10 new crawlers that have been detected. This has also involved adding a 4th Crawler Spam filter, details of which are above. This new filter has already been added to the segment code above if you wish to remove the spam from historical data as well.

Michael is a successful entrepreneur with a strong background in all areas of web development, online marketing, graphic design and IT. As the current owner of Improve Position, as well as a small range of other related businesses, Michael's enthusiasm shines through with his passion to help others understand and succeed in the world of online business marketing.

Leave Us Your Comments
  • Hi, Michael — thanks for visiting my blog and leaving a comment to check out this post. You have a very thorough post here on the topic of referral spam! Great tips. I’ll share on my social. Cheers!

    • Hi Stacy. Thanks for taking the time to pop by, have a read and leave a comment…much appreciated. Really hope people are finding this useful. If you need any assistance in setting this up, either for yourself or clients, just let me know. I have some updates to make to the filters this month, so will add them in shortly. You can signup to my newsletter to get notifications of when these filters are improved further as well. Thanks again, Michael.

 

Learn About Us

We are a full service agency that deliver compelling digital marketing solutions. Our winning formula and experience helps to deliver outstanding results across several key business areas.

Request a free quote

We offer professional SEO services that can help your website increase organic search drastically and compete for 1st page rankings of highly competitive keywords.

More from our blog

See all posts