Go to Blog

How to Get Rid of the Ghost Referrals in Google Analytics

Ondrej Kubala
How to Get Rid of the Ghost Referrals in Google Analytics

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 eveneditors.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.

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:

Audienti GA View

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.

GA View

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:

New Filter Button

Select “Custom” in Filter Type and choose Include.

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).*
  • .*event\-tracking\.com.*

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=/”;


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.

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:

Google Analytics

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.

Google Analytics

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:

Google Analytics

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


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.

Like this post? Follow us on RSS and read more interesting posts:

Ondrej Kubala is online strategy consultant and growth hacker at Audienti where he helps grow this promising startup.
Share this post


2000 symbols remain
SEO Bristol UK
Hi Ondrej,

Fantastic information!

I hope you don't mind but I added more information to your article and created a video to help people with the 'referrer spam' issue and how to solve. Hopefully, it will help a few people with this very irritating flaw in Google analytics?

Great article Ondrej. These spammers and even ghost link websites that show up in the "behavior" section of analytics are a pain in the you know what. Why do they like messing with people's analytics? Have you found that these spammers are specifically targeting websites with Google Analytics? I wish Google would get off their behinds and deal with this.
Ondřej Kubala
Hey Matt, I don't know about other analytic software that would have the same problem but I think that switching it to anything else than Analytics would probably make your data clean.
Brian Loebig
Great info Ondrej! What do you think about using a "valid hostname filter" to remove these type of ghost referrals? This would be a single filter that only allows referrals from domains where the GA code originates from. I read about it on this blog recently: http://www.ohow.co/what-is-ref...
Ondřej Kubala
Brian Loebig
Hey Brian,

It's actually one of the filters that I mentioned here in section

#2 Filter Ghost Traffic by Wrong Hostname
Thanks for the article, Ondrej, I found it really helpful. I had been puzzled as to why a client's analytics recently started showing porn sites as referrers (and he had never visited these sites). These spammers are a royal pain and also create extra work for us!
Ondřej Kubala
You're right Kirsten, thanks for your comment. We can all hope that one day guys at Google will fix it.
Way too much work.


create a secondary property use the new UA ID number ending in -2 and boom no more ghost referrers.
Ondřej Kubala
Thanks for sharing your stuff with us. Anyway, it's not working for me.

Check out this print screen http://screencast.com/t/JBwZP0...
Great article!
Ondřej Kubala
Claudia Sies
Thank you :)