How To Easily Remove Ghost & Spam Referrals from Google Analytics

Michael Burke, the author, has over 10 years of experience working in the Internet sector

Michael Burke

Web & Mobile Expert, Technical Director of Emerald Creative

Every business that runs a website will have some form of analytics software on there. This software monitors the number of visitors that come to the website, what they were using to view the site on (whether on a desktop of mobile device), where they are from etc There is a whole wealth of information that can be collected using analytics, and this information can be used to improve the usability and visibility of your website to your visitors.

The most popular analytics software on the market is Google Analytics, and is used by millions of websites worldwide. And one of the most important metrics recorded by this software are “Referral Links”. Referral links are websites that have linked to your website, and visitors from those websites have clicked on a link there to visit your website.

However Google Analytics has a problem with referral links. It's problem is that this metric is being targeted by people who want you to visit their websites when you go to investigate the referral links. These referral links go to websites that are either selling some magical SEO services, or want you to unknowingly download malicious software. Worst of all, it skews your analytics data so that you think you're getting more referral data and visitor data than you actually are. But never fear – there is a way to stop this!

Embrace the power of the filter

One of the features of Google Analytics is that it allows you to create filters for your data. These filters give you the power to manipulate the data that you collect so that you can get more accurate data from your visitors. In this case, we're going to use the filters to weed out these spam referral links.

There is however a drawback to these filters. Once you create a filter they will only filter new data to your website. They will not work on past data unfortunately. I will show you however a way to manipulate your past data to help you get a better understanding of your website's usage without this spam traffic at the end of this tutorial.

This tutorial will cover three key areas:

  1. Create A View For The Filtered Data
  2. Create The Filters
  3. Set Up Retrospective Filtering

This tutorial has been written on the assumption that you already have a Google Analytics account set up and that you have access to the admin portion of your account. If you have neither of these you will need to set these up before continuing.

Step 1: Create A View For The Filtered Data

To start with we are going to create a new View for our analytics data. We're doing this so that you are separating your filtered data from your original data. This will allow you to cross check between the two data sets so that you not only know what traffic to filter in the future, but you'll also make sure that you aren't blocking legitimate traffic to your site either.

Firstly you will need to login to your Google Analytics account. Once you've logged in, click on the Admin link at the top of the page. Doing that will take you to the following screen. Once there, on the right hand side of the screen, click on the dropdown menu highlighted in red below. There you will see a link Create new view, highlighted in green.

Once you've clicked on the Create new view option above, you'll be presented with the screen below. This will allow you to create a new view for our filter to work on. Select the options that you can see in the screenshot below. You can name your view anything you want, but for this tutorial we will be using the name “Filtered Data” for our view. Your location and timezone details may differ from what's below, so please adjust accordingly. Once you've done that, click on the blue Create View button.

Doing that will take you back to the screen you first started on when you clicked on the Admin link. As you can see, on the right hand side, it will automatically select your newly created view.

Step 2: Create The Filters

You will then click on the Filters link highlighted in red below.

This is where all your filters will be listed when we create them. This will be handy in the future when you go to add a new filter for another purpose, and you'll be able to see previous filters and what they do. So, to create a new filter, click on the red New Filter button shown below.

This screen is where all the filtering magic takes place. You can name the first filter anything you want. For this tutorial I've named it Ghost Filter #1 – as we need to create two filters. For this first filter, you will be targeting the website hostnames only. So for this example we want to filter two websites: seo-success.com and buttons-for-websites.com. To do this we will use something called “regex”. You don't need to know exactly what it is, but you need to make sure that the websites you enter follow the same sort of pattern as below:

*seo-success\.com|buttons-for-websites\.com*

You must always type a backslash “\” before any period used. So if your website uses .co.uk, you will have to type .co.uk. Also, when putting more than one website in separate them with the “|” character. You will find this on your keyboard by holding down the Shift key and then the backslash “\” key.

Once you've done that, click on the blue Save button at the bottom of the page.

That's your first filter completed! But that filter will only capture around 95% - 98% of these spam links. To fully eliminate them we will need to create a second filter. To do this, click on the red New Filter button. You'll go back to the same screen, but you will need to select different options as you can see below.

This filter will target the same sort of websites as before, but we won't be including the .com's, the .co.uk's etc of the domain name. This is so that we filter traffic from these sites across all possible domain names. This time though I have done the hard work for you, and have put together this line of code that will target the worst offenders.

*darodar\.|semalt\.|buttons-for.*?website|blackhatworth|ilovevitaly|prodvigator|cenokos\.|ranksonic\.|adcash\.|share.?buttons\.|social.?buttons\.|hulfingtonpost\.|free.*traffic|buy-cheap-online|-seo|seo-|videos-for*

Once you've added the above code, click on the blue Save button below.

Success! You have created two filters that will get rid of nearly 100% of the referral spam traffic that you had coming to your website.

Step 3: Set Up Retrospective Filtering

The filters we have created will work on all future traffic that our websites receive. Unfortunately though these filters only work on future traffic, they can't be applied to data your analytics has already recorded. But, there is a way to at least improve the quality of your previous data.

To start, click on the Home link at the top of the screen that you're on. You will go back to the home page of Google Analytics that lists the websites that you have analytics on. What you will notice is that the view you have created is now listed. But you don't want to use that for this exercise, you want to go back to the original view. Clicking on that you'll be taken to the Dashboard of your analytics data. On the right hand side, you will need to click on Acquisition, then All Traffic, then finally Referrals. If you're not quite sure what I'm referring to, look at the following image – this will be your map!

When you click through those links, you'll be then taken to the following screen:

Near the top of this screen, above the graph, you'll see a Customize link. Click on that, and you'll see a fairly complicated page. You can ignore most of this, what you need is at the bottom of the page, like this:

Like you did when creating the filter, you're going to add the websites that you want to remove from your data. Again for this tutorial, I'm going to use seo-success.com and buttons-for-websites.com as websites I want to remove from my data. You'll be different, but remember the pattern:

*seo-success\.com|buttons-for-websites\.com*

Underneath where you added the filter on this page, it will ask you what view you want to apply it to. Make sure you apply it to your original view, as it won't work for the view you created at the beginning of this tutorial. Once done, you will click the white/silver Save button. It will then take you back to the previous page, minus the websites you've added to the filter.

Success! You've Done It!

That's it – you've created filters that will remove most, if not all, of the ghost/spam referral links plaguing your analytics. From this point on you will have only correct information being displayed for your website, meaning you can make correct decisions regarding your website.

I hope that you have found this article useful. I have certaintly found this technique super useful for the Emerald Creative website, and it's allowed me to grow the website and business accordingly. There will be people you know that are you like, that are like me, who won't know about this technique. So please share this article with those people and I guarentee they'll be over the moon with what you've sent them.

Posted in #TuesdayTip, Analytics, Tutorials on 25th August 2015


Most Recent Articles

View More Posts


Sharing Is Caring... And Free!

If you have found this article interesting or useful, please consider sharing it using the buttons above!