Ghost referrals and how to remove referral spam from Google Analytics

Ghost referrals in Google Analytics are spam entries in your Google Analytics that are directed at developers. They pollute your data with fake visits, making your Google Analytics data less valuable and can hurt your site and brand.

Has your site been affected?

Chances are, yes, your site has been affected. The easiest way to check is to open a report in Google Analytics, and go to Acquisition > Overview > Referral. If you see sites like,,, and you have been compromised.


How does it work?

These spammers are loading Google’s Analytics javascript and inserting random Tracking ID numbers (similar to UA-000000-01) into their code and recording a visit to a website without ever actually visiting the site. If they happen to randomly choose your Tracking ID, a spam referral is added to your stats. We have seen thousands of these random attacks on our sites and our customer’s sites. This means you are receiving false data that affects everything from bounce rate to the value of your Adwords Campaigns.

What can I do?

Since the spammer never actually visits your site, server-side methods of blocking these referrals (such as .htaccess rewrite rules) are not effective. The best method we have found to stop referral spam is to use a set of filters in Google Analytics.

Step 1: Hostname Filter
The first filter is to only record visits from valid hostnames. Most of the ghost referrals have a blank or random hostname. We want to create a filter that only includes valid host names for your site.


Step 2: Known Spam Filter
There are some spam domains that use the correct hostname, but still send your site bogus traffic. For this filter we are doing an exclude on known domains using the Campaign Source.


You will need to monitor your site to see what domains are spamming your site, but here is a list to get started:


Note: Google Analytics filters are applied to new data coming in to the site and do not affect existing data. So if you apply the filtering techniques outlined below, your existing reports/data will still include the referral spam that was previously recorded. To eliminate referrals from existing reports, you’ll need to create a new Advanced Segment. Also, it’s good practice to not filter your default view and do so on a new view for testing. Once you are happy with the results, you can move the settings over to your normal view (while still keeping a view that has all data).

We're based in Virginia, MN...
but we work with clients from all over

(218) 741-9544