How to Get Rid of the Ghost Referrals in Google Analytics

Ondrej Kubala
#growmance on fire
Published in
6 min readMay 22, 2015

--

You’ve probably been there and don’t even know it yet.

Your analytics are crowded by them. I know what you’re thinking:

“Wow, that’s great! Somebody is linking to my website and I’m getting a lot of referrals from there!”

But the reality is not that good.

You actually aren’t getting any traffic. There are no visitors coming to your website from referring website. And what’s worse, it’s messing up your Google Analytics reports.

Why, you might ask, am I receiving this phantom traffic?

Well, these non-visitors shouldn’t be counted since they’ve never been to your website. What you’re getting is distorted by fake data.

So, who is actually interfering with your Google Analytics?

You can find out who is giving you ghost referrals by looking under Reporting > Acquisition > Referral. Usually, the referrers are something like:

  • best-seo-offer.com
  • free-share-buttons.com
  • semalt.com
  • buy-cheap-online.info
  • ilovevitaly.co
  • buttons-for-your-website.com
  • or even editors.choicexxxx.hulfingtonpost.com
  • darodar.com

That’s not a complete list, as ghost referrers are constantly evolving. Because they are growing and changing their structure and technology, we will probably never be able to get rid of them completely. However, this tutorial you should be able to eliminate most of it.

Bonus: We’ve created #growmance — a Slack community built specifically for growth hackers and other Analytics junkies to hash out growth ideas in real time, with input from around the world. You can sign up here (it’s free to join).

How to Remove Ghost (or Other) Spam Referrals From Google Analytics

There are couple ways to do this, and I’ll explain each of the steps later in article:

  • Using Google Tag Manager (set up an exception where you don’t fire tag if it the referrer doesn’t match the regex)
  • Google Analytics Filters (filtering ghost referrals from defined sources)
  • Placing cookies into visitors’ browsers and checking in analytics that this cookie was placed

#1 Before You Start Doing Anything in Analytics, Back it Up

Your data is valuable. Anytime you you do anything that would influence the structure of it, you should do backup first.

There are many ways to back up Analytics. Always preserve your raw data.

For example, my Analytics looks like:

To clarify what each of these are:

  • Unfiltered view: this is just raw data without any filter applied
  • Test view: on this view I’m testing my filters before applying them on my main view
  • Master view: filtered correct data with goals and custom segments and filters

The procedure with my GA account is simple. Before I apply my filter on master view, I’m testing it on this view because I don’t want to corrupt my valuable data.

#2 Filter Ghost Traffic by Wrong Hostname

So go ahead and open your Analytics. Click on Audience > Network. Once you open it, click to Hostname and what you see are all hostnames that visitors used to access your analytics.

You of course don’t want to run your Analytics script on domains other than yours. In the image above you can see darodar.com and other ghost referreres that are messing with Analytics.

To filter this traffic, click Admin. On the right column select the right view where you want to apply your new filter and click Filters.

Then click New Filter button:

Select “Custom” in Filter Type and choose Include.

Now File Pattern should be regex matching your hostname. On my website it’s this: ^(www.)?audienti.com$ and it works whether the hostname is with or without www.

This should work and filter out any traffic that doesn’t happen on your hostname.

#3 Filter Out Traffic from Bad Refferrals

First, filter to remove traffic that happens away from your domain.

But what if there’s a spambot that enters on your website?

Well, there are two simple solutions:

First solution is to create a new filter.

Head over to your Filters, click New Filter (the same as it was before).

Select Filter Type to be Custom, Filter Field is Referral, and Filter Pattern is this long regex (source):

  • .*((darodar|priceg|semalt|buttons\-for\-website|makemoneyonline|blackhatworth|hulfingtonpost|bestwebsitesawards|o\-o\-6\-o\-o|(social|simple\-share)\-buttons)\.com)|(econom\.co)|(ilovevitaly(\.co(m)?))|(ilovevitaly(\.ru))|(humanorightswatch(\.org)).*
  • .*((best(websitesawards|\-seo\-(solution|offer))|Get\-Free\-Traffic\-Now|googlsucks|theguardlan|webmaster\-traffic)\.com|(domination|torture)\.ml|((rapidgator\-)?(general)?porn(hub(\-)?forum)?|4webmasters)\.(ga|tk|org|uni)|(buy\-cheap\-online)\.info).*

And there’s also a feature (not particularly efficient) that Analytics provides to filter out all spiders and bots. You can find it in Admin > and under your View choose View Settings and scroll down to Bot Filtering and check the option.

#4 Filter Spam Referrals Traffic by Placing a Cookie

Solutions mentioned above won’t last forever because as you can see, there are more and more spam bots being created every day.

Although, here’s one solution that has really worked for Audienti website. I found it on Lunametrics blog, but tweaked it little bit.

So the principle is simple:

  • You expect that a physical visitor of your website has a browser and that a spam bot doesn’t
  • On your website you place a cookie on his browser
  • Read the cookie in Google Tag Manager and pass it to Analytics
  • Analytics will only include visitors with this cookie

I’d say it’s an advanced technique so you should discuss it with your web developer. However,if you understand a little bit of how you can code simple Javascript into your website, it’s going to be piece of cake for you.

I’m presuming that you use Google Tag Manager already on your website. If not, you should read this article on how you can improve your site performance by using tag manager.

Setting Up Cookies in Your Visitor’s Browser

Placing a cookie in your visitor’s browser is very easy to do. There are at least two ways how to do this. First option is to fire tag in Tag Manager, but in the next step we will read that a cookie in Tag Manager is most likely not going to be found in your Analytics (even if you set correct priorities).

Therefore I recommend you create a cookie manually and add this simple code snippet to your website’s footer script area (after </body> tag):

<script type=”text/javascript”>

document.cookie = “dev-status=may2015; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/”;

</script>

Basically, you are creating cookie dev-status with value may2015 that expires in in far future. This is the value that we are going to read later in Google Analytics. If you placed it using Google Tag Manager, the same Google Tag Manager won’t find it in that same moment and in GA you won’t get the value in the first session.

Create Custom Dimensions

Head over to Analytics Admin, click to Custom Definitions and Custom Dimension.

From your Analytics mark down an index number because you are going to use it later.

Read the Cookie Value with GTM

Now to read the value of the cookie we have to create in GTM a variable that grabs value of our cookie. So in GTM go to Variables, click to New and proceed like this:

Once you’ve done that, head over to your GTM and select the Google Analytics firing tag. Open it and scroll down to More Settings, then find setting called Custom Dimensions. Insert your index and variable dev-status that you just created.

Include Only Traffic with Cookies

The next and final step is to get Analytics to recognize visitors with the cookie and include only those visitors into the final report.

We’re going to do that in Filters. So create new filter with these parameters:

This was the final step. Now you should be able to see correct data in your Analytics.

Conclusion

Whether you are marketer or you do more technical tasks on your website, you should always keep your data clean. Now you will be able to filter out this really irritating way of spamming. Do you have any questions or comments about this process? Please let us know in the comments.

We’ve created #growmance — a Slack community built specifically for growth hackers and other Analytics junkies to hash out growth ideas in real time, with input from around the world. You can sign up here (it’s free to join).

Originally published at www.semrush.com on May 22, 2015.

--

--

Ondrej Kubala
#growmance on fire

Full stack developer — Ruby on Rails / React.js. You can hire me here: http://quickmonkeys.com