How to block spam traffic in Google analytics.

How to block spam traffic

Why you should block Spam Traffic in Google analytics

Google analytics is a very useful tool when it is accurate. The analytics can show you the pages you have the highest traffic on, where your traffic comes from, demographics of your audience and more.  But what happens if you have spam referrals and traffic? Your analytics get skewed and you have false information to rely on. This will give you a fake impression on what actually is happening with your website. You will have page views that are non existent. You can also receive spam referral traffic that uses your site as a redirect loop to hide black hat trickery. So what can you do to make your Google analytics more accurate? Continue reading and learn all about ghost spam, and referral spam and how to block spam traffic in Google Analytics.

What is spam traffic?

Spam is any traffic in Google analytics that is inorganic or not real page views. There are several big analytic spammers out there, the biggest one being Vitality. Then you have smaller spammers that use spiders and bots for referrals. These are called Classic Referral Spam.

  • Vitality spam
    • Vitality spam is considered a Ghost Spam, meaning it never actually visits your site. This guy just really hates Google and has made it his goal in life to spam Google analytics like crazy. Spammers like Vitality will inject fake traffic in your analytics by using your tracking id.
  • Classic Referral Spam
    • Classic Referral Spam refers to spammers who use the Referral Spam employ the help of bots and spiders to visit your site and show a referral from there site. When most people see a new referral site they will investigate it. This gives the spammer traffic. Now imagine this in a large scale with thousands of visits per day. This is black hat trickery to rank them higher in Google.

How to block spam traffic

There are several ways to block spam traffic from showing in Google analytics. The ways differentiate depending on the type of spam you are receiving. For Ghost Spam you will need to set filters within the analytics dashboard. To block Classic Referral Spam you will be using your htaccess file. Lets get started.

  • How to block Ghost Spam

    Since Ghost Spam doesn’t actually visit your site you will need to set filters in Google Analytics.

    • Note:  We offer no guarantees about the workings of these filters and take no responsibility for any damages that might be caused by either correct or incorrect implementation of the filters below. Be especially careful if you decide to apply them, but have no prior experience setting up filters in Google Analytics. Even experienced users might want to try these on a test view first. Also remember that it is best-practice to keep an unfiltered “backup” view at all times.
    • Filter #1 Language Spam

      Languages should be no more than 5 characters and typically are the abbreviations of the language ie. en is English and es is Spanish. We will set a filter for invalid characters in the language expression.


      Follow the diagram below to set up the filter.

Language Spam Filter

  • Filter #2 Browser Spam

    This filter captures any sequence of 3 or more non-white-space characters, followed by a dot, followed by a sequence of 2 or more letters and looks like so:


    Your filter should look like this:

How to block Brower Spam Filter

  • How to block Referral Spam

    Since referral spam is a visit to your site we will be editing the htaccess file. First you will need to login to your hosting acount. Once logged in locate the file manager and open it. You will see a popup that ask what files you want to view. Select webroot and check show hidden files. Now you should be on  screen with various files of your website. The first view is of the webroot folder. Scroll down until you see .htaccess. You will need to right click and choose edit code. This is where we will be adding some code. Under your redirect code paste the following:

  • # Block Russian Referrer Spam
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly.\.ru/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.org/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.info/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*iloveitaly\.ru/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*econom\.co/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*savetubevideo\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*kambasoft\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*buttons\-for\-website\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*darodar\.com/ [NC]
    RewriteRule ^(.*)$ – [F,L]

    This should block most if not all referral spam. If you still get spam from other sources simply add a new line following the code above.


It is up to you if you want to filter out spam from Google analytics. Yes it will lower the amount of page views you see currently. However, this will give you a better view of what is going on within your site. It will also show you where to focus your attention on for social media and referral traffic to get real views and engagement. The changes will not show in your old traffic reports, it will only take affect from the time you set them. If you need help with any of the filtering feel free to contact me.


How to block spam traffic

2 thoughts on “How to block spam traffic in Google analytics.”

Leave a Reply

Your email address will not be published. Required fields are marked *