Stopping bot referral traffic in Google Analytics

Many businesses have been bothered by Ghost referral spam websites. They usually appear in your websites’ statistics and Google Analytics. Should you be worried about these irrelevant sites stealing your band weight? They do not harm your website nor do they have access to your webpages. These spammers use dynamic IPs and scripts in order to drive traffic to their websites. Some of them use CloudFlare IP. Their scripts target your websites. They hit random blocks of Google Analytics tracking IDs. We’ve seen this porn spam show up in some of our clients’ Google Analytics accounts. It is important to understand between ghost spams and scripts that do actually scrape your websites’ contents.Many website owners are wondering why Google’s bot filter doesn’t stop these spammers? It is because they never actually click at your websites.If you see them in your website ‘statistic do not click at them. If you do, more spammy sites will be pointed to your website.

Spammers want to get website owners click at the referral sources. By clicking, they are driving you to another website with more spam and irrelevant ads. These spammers are hitting thousands of websites on daily basis, in an attempt to drive traffic back to their crappy websites. They may also be directing traffic to their affiliate sites, where they earn money if visitors buy something. Spammers don’t know whose websites they are targeting to, hence their scripts are not set on various hostnames.

Many of these websites use CloudFlare IP. The following shows an example of spammy sites.

Stopping bot referral traffic in Google Analytics

Here are some of spammy websites which spam via cpanel. These are called ghost spams:

  • Click at the Admin in your Google Analytics at the top of your screen.
  • Go to the view in which you want to set the filter. Make sure to always have an unfiltered view of your traffic. Filtered traffic cannot be retrieved. Monitor your websites and keep an eye on “All Website Data view”, with no filters, and then create a new view where you will place your custom filters, turn on Google’s bot filter, set up your goals, etc.

Name your filter. In our example we’ve used Block  Spam.

For Filter Type, choose Custom.

  • For Filter Field, choose Campaign Source.
  • Add the referrer to the Filter Pattern field.
  • To block several referrers, you can use a regular expression.
  • Click Save.

Here is how to filter these spammy websites.

  1. Click Add Segment on your screen.
  2. Choose New Segment.
  3. Under Advanced, click Conditions.
  4. Change “Include” to “Exclude.”
  5. Change the default “Ad Content” to “Source.”
  6. Use “matches regex.”
  7. Start to type the referrer. It should come up in the auto fill drop down, so you know you have a legitimate referrer to you site.

Another way is to write the following code in your htaccess file:

BrowserMatchNoCase bad_agent
Order Deny,Allow
Deny from env=bad_agent

The red color in the code above is the domain which I want to block.  You can use the same code for your own website just replace the red color domain with the one you want to block.

The following list below is websites which feed off one of my domain’s band weight and spam via Cpanel in hopes of getting clicks. To stop them i just add these rewrite rules in my htaccess file. Legitimate websites’s URLs  are hidden, the ones which are showing excluding the buffly urls are spam. If you click at these URLS, you land on their pages and there is no trace of your link on those pages. They do it to get click, so the best thing is not to click at them.


RewriteCond %{HTTP_REFERER} [NC,OR]
RewriteCond %{HTTP_REFERER} [NC,OR]
RewriteCond %{HTTP_REFERER} ^([^.]+.)*? [NC,OR]
RewriteCond %{HTTP_REFERER} ^([^.]+.)*? [NC,OR]
RewriteCond %{HTTP_REFERER} ^([^.]+.)*? [NC,OR]
RewriteCond %{HTTP_REFERER} ^([^.]+.)*? [NC,OR]
RewriteCond %{HTTP_REFERER} ^([^.]+.)*? [NC,OR]
RewriteCond %{HTTP_REFERER} [NC,OR]
RewriteCond %{HTTP_REFERER}[NC]
RewriteRule .* – [F]

You can also block these URLS’s IP addresses in your .htaccess or robot.txt files. However they use dynamic IP addresses and blocking is no use. Just don’t click at these urls when you see them and follow my instruction above.


Need help with Google Analytics or website analytics? Let’s hear it.  Contact here