Block Google Analytics Spam

The referral spam in Google Analytics is a new breed of problem. This page is dedicated to eradicating it from your GA statistics.

Referral spam is easily among the largest nuisances that website owners and admins are faced with every now and then. We have created the below article due to a specific case of referral spam that has been bugging some of our readers lately: If you, too, have fallen victim to this referral spam, our aim is to first explain to you exactly what it is you’re dealing with and how you can have it removed from your life, ideally once and for all. For that very purpose we have designed a special removal guide, with the help of which you will be able to effectively block the spammers. But do read what we have to say first, before you skip over to the instructions.

What referral spam really does and what is all about

Now, you may or may not know exactly what it is that is doing and why it’s targeting you. In order to gain a better idea of that, we would first like to point out the different between the two types of existing referral spam. One of them is what’s known today as classic referral spam and the other is – ghost spam. belongs to the latter category, but the former is where referral spam really originated. The point of it all boils down to certain people wanting to gain more traffic for their websites. And to achieve that, they employed the services of bots and crawlers that would be sent to tens and even hundreds of thousands of other websites. Those bots and crawlers would, in turn, generate this for those websites, but with a near 100% bounce rate and little to no session time.

This would logically prompt the website owners to want to investigate and check out this other website that seems to be opening theirs and leaving it that same second. Once they do that, they will have generated traffic for that spamming website and the mission will have been completed. However, this practice eventually came to an end thanks to the experts over at Google. But the spammers didn’t remain beaten down for too long, so they improved on the old concept and came up with ghost spam – what we have on our hands today. Instead of sending bots and crawlers, they took to the GA stats of the targeted websites directly. So, hence the name ‘ghost’ spam – they generate these ghost visits, or simply just impressions of actual visits. As a result, the website owners are again tricked into believing some strange site has been opening theirs and leaving it immediately.

This is, in fact, even better, because spam like doesn’t really affect you actual traffic count, or your ranking or anything else of importance. The single thing that is affected is your statistics in Google Analytics. The problem with that, however, is that over time, the longer the ghost spam remains active and keeps spamming you, the more inaccurate your stats will become. So at some point you will find yourself looking at a picture so distorted, you will completely lose perspective over the real state of affairs. And the only worse than doing nothing about that will be to resort to something called the Referral Exclusion List. This is a great tool, which many users mistakenly believe to be the means of combating spam like

What will happen if you enter the spammers into that list is that GA will head over to investigate the reported visits. And remember what we said about them only being impressions? Yeah. GA will not be able to find a source, so instead of doing something to stop the spam, it will start recognizing those hits as genuine traffic. We strongly advise anyone against doing that, because things will only go south from there. What we can recommend is that you use the simple instructions we’ve included below to block the spammers and then invest in a better hosting service. When it comes to protecting your website from spam, hosting is everything, because it is basically what provides all the spam filters and other safety mechanisms. And if you’re having problems with your current hosting, then maybe it’s time to change it.

Block Referral Spam

STEP 1: In your Analytics account go to Admin —> All Filters.

pic 1(1)

STEP 2: Next, click New Filter and add in the Filter Name value.

STEP 3. Select the Custom Filter Type. In the Filter Field —> Campaign Source. In the Filter Pattern text box, add and click the Save button at the bottom of the webpage.

Pic 2(1)

Blocking referrer spam through .htaccess

If you know how to access your .htaccess file, you just need to input the following code in there:

RewriteCond %{HTTP_REFERER} [NC,OR]
RewriteCond %{HTTP_REFERER}
RewriteRule .* - [F]

If you don’t know how to access it, do the following:

Login to your cPanel account —> File Manager —> click the check-box “Document Root for—> your website. A side note: click on “Show hidden Files” and then Go. Find the .htacess file, right click it and choose Code Edit. Input the code I gave you and Save Changes.

Did we help you? A thank you in the comments goes a long way to warm our hearts!


About the author


Violet George

Violet is an active writer with a passion for all things cyber security. She enjoys helping victims of computer virus infections remove them and successfully deal with the aftermath of the attacks. But most importantly, Violet makes it her priority to spend time educating people on privacy issues and maintaining the safety of their computers. It is her firm belief that by spreading this information, she can empower web users to effectively protect their personal data and their devices from hackers and cybercriminals.


Leave a Comment