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 in order to do so, we need to know how to block sites that are 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 fairly easy to spot since most of the traffic has a 100% bounce rate, or at least an abnormally high bounce rate.

The purpose of referral spam is to trick curious webmasters into clicking their link 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 want to sell their SEO and PPC services to website owners as well. 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, it is possible to block some spam referrers through your .htaccess file alone, as some crawlers such as semalt actually do 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 are only targeting 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):||||

  1. Verify your filter – it will show you some sample data from the last 7 days before and after applying the filter. You should see some referrers hitting you before the filter was applied and not showing up at all after. However, if they didn’t hit you in the last 7 days, they won’t appear at all.

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

Even though you’ve stopped the referral spammers that are currently hitting your website and Analytics you need to keep an eye out 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.