When you spend enough time in your analytics, certain referrers of traffic to your site will definitely stand out if they keep appearing. Whilst referrers are typically a good thing as it means somebody is sending traffic to your site, this isn't always the case. In this post we will cover how we blocked a source of referrer spam from this site, however this same method can be used for blocking any unwanted referrers.
How to Block SPAM Domains From Accessing Your Site
The first step I undertook was to block the domains via my .htaccess file. You should find that all WordPress sites have one of these in your websites root directory. The code that I used is pasted below and was inspired by Paul Thompson from Buzzwords to Business. You can add the code to the bottom of your existing .htaccess file making sure to include any domains causing referrer spam. This should prevent further abuse from the problematic domains but unfortunately it is an uphill struggle and new domains are popping up all the time, so you may need to update this file over time.
The second and final step I took was to filter the referral domains from Google Analytics so that the spam attacks did not affect the accuracy of my analytics. The above methods should work for any unwanted referrers that you need to be blocked from accessing your site and skewing your statistics in the process.
“Data that is loved tends to survive.” — Kurt Bollacker, computer scientist, open-source advocate