Getting an accurate analytics report for your website or blog is one of the important things to analyse the further steps that can be taken for improving the site. When you own a website or blog, it is usual that many hackers and marketers might try to spam your site just to outrank you and get them on the top of the search engine. In most of such cases, you seem to get a referral traffic which can be blocked easily. Learn how to block unusual spam referral traffic to your website.
Yesterday, I noticed an unusual spam referral traffic which was bombing my Google Analytics report a lot. When I initially looked at it, I was surprised to see such a peak, but I was bit sceptical because it was unusual.
Traffic from lifehacĸer.com was flooding or bombing my Analytics report. You just need to note that the letter "ĸ" and not the usual "k". The traffic was very unusual that most of the bloggers were getting the same traffic and trying hard to get rid of them.
The traffic did not harm any websites or blogs but just trying to hit the homepage. It was clearly a bot traffic which is not highly recommended on Analytics report.
Exclude Unusual Spam Referral Traffic in Google Analytics Report
You can always hide or block unusual spam referral traffic on Google Analytics. Here is what you need to do:
- Login to Google Analytics Dashboard.
- Under Admin Menu, choose All Filters in Account section.
- Click on Add Filter button.
- Provide a name for your Filter.
- Choose Custom as your Filter Type.
- Select Exclude and choose Referral as your field.
- In the Filter Pattern text box, paste the domain that you want to remove from Google Analytics.
- Add your site to the right Selected Views list and Click Save.
That's all your Google Analytics report will exclude the unusual spam referral domain and gives you a clear Analytics report.
Server Level Blocking Spam Bots
Do you think that just hiding it from Google Analytics will solve the problem? Your server will still serve pages to the spam bots utilising your memory and CPU. It gives a bad impact on performance when real people are trying to load your website.
What can be done to block unusual spam referral traffic from serving your website?
The answer is, you can return or redirect to 444 for spam bots, which is trying to access your site.
Nginx
If you are running a Nginx server, open your nginx.conf or whatever the configuration file that is available for your Nginx.
if ($http_referer ~ "referraldomain1\.com|referraldomain2\.com|referraldomain3\.com") { return 444; }
Save the configuration file. Restart Nginx and you are done. Your web server will now point spam referral to 444 error, which means, connection closed without response.
If you do not know which configuration file is your Nginx using, try this command to find out.
nginx -t
Apache
If you are running Apache web server, you can follow the below steps to block unusual spam referral traffic to your website or blog.
Copy the below rules to your .htaccess file. So, whenever a traffic comes from the domain mentioned in the file, it blocks.
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} referraldomain1\.com [NC,OR] RewriteCond %{HTTP_REFERER} referraldomain2\.com RewriteRule .* - [F]
Conclusion
Blocking traffic in the place of the web server is the recommended way compared to hiding from Google Analytics reports. Blocking at server level will not affect other users who are actually visiting your website. Your memory is used less. The web server is not going to process PHP files or any other server-side scripting languages and serve HTML sites. Blocking bad spam bots in web server will just return 444 instead of 302 Found.
Share your experiences below.