How to Stop and Prevent Referral Spam

These days, almost everyone is being hit by referral spam, and it is unlikely that Google will step in and stop it any time soon. This means we’re on our own to deal with it. But to do so, we need to know how to block sites sending us referral spam.

A can of spam, crossed out.

What is Referral Spam?

Referral spam, also called referrer spam, is fake traffic that appears in your Google Analytics reports as traffic that was referred from another website. Thankfully, referral spam is relatively easy to spot since most traffic has a 100% bounce rate or at least an abnormally high bounce rate.

Referral spam aims to trick curious webmasters into clicking their links in Analytics and driving their own traffic from those clicks. Referrer spam URLs typically lead to affiliate redirects, ads, and occasionally malware. Occasionally you will even see referral spam websites (such as that also want to sell their SEO and PPC services to website owners. If left unchecked, referral spammers can pollute and skew your Analytics data.

A Google Analytics page, showing several referral spammers.

How to Block Referrer Spam

It is important to note that most referral spammers don’t actually visit your website. Instead, referrer spam is typically generated by pinging your tracking ID (UA-ID) using Google’s Measurement Protocol. However, blocking some spam referrers through your .htaccess file alone is possible, as some crawlers, such as Semalt, visit your website.

So how to block certain websites that do nothing but spam us?

Here is some example code that, once added to your .htaccess, can block some spam referrals (Note: always make a backup of your .htaccess file before making any changes, as the slightest error can take your site offline):

##Block Referral Spam
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]

In addition to blocking referral spam through your .htaccess file, you should also add filters to your views to exclude future referral spam in case they only target you through Analytics.

  1. Open your Analytics account and navigate to the Admin tab.
  2. Under View Column, Select Filters
  3. Click Add New Filter.
  4. Give the filter a name, such as Spam Referrals.
  5. Under filter type, select custom and use Campaign Source as the filter field.
  6. In the Filter Pattern box, enter the spam referral domains using the following pattern as an example (be sure to separate domains using the pipeline character and do not end the pattern using the pipeline character):
  7. Verify your filter – it will show you sample data from the last seven days before and after applying it. You should see some referrers hitting you before applying the filter and not showing up afterward. However, if they didn’t hit you in the last seven days, they won’t appear.

An example of an Analytics page with filters applied, now free from referral spam.

Even though you’ve stopped the referral spammers currently hitting your website and Analytics, you must look for spam referrers in the future. New referral spammers are showing up constantly, and you need to keep on your toes. But if you check up on your referrers at least every month and add new filters as needed, you should know how to stop referral spam once and for all.

Ready to Collaborate? Contact Us!

Please enable JavaScript in your browser to complete this form.
Blog Sidebar



Please enable JavaScript in your browser to complete this form.
Newsletter Signup