Internet Marketing Tips, Suggestions, & Ramblings

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.

About Garry Grant

Garry Grant is a veteran expert in search engine optimization and the digital marketing industry. With nearly 20 years of experience, Garry has successfully built a multi-service operation at SEO, Inc., developing proprietary technologies through complex strategic solutions. He has extensive experience in key initiatives and operational responsibilities grounded in information technology and performance management.

Garry’s expertise and esteemed reputation, coupled with SEO Inc.’s impressive client success record has earned him such accolades as Entrepreneur Magazine's 2005 Hot List for the Hottest Internet Property, Inc. 500 2007 Honorary award for Fastest Growing Private Company in America, an Inc. 500 top 50 Company in San Diego, and interviews with The New York Times, The Wall Street Journal, WIRED, Entrepreneur and The Huffington Post.

Garry Grant began his online career in 1993 creating strategic Web and e-business solutions for, The Rush Limbaugh Show, Premiere Radio Networks, Clear Channel Communications, EarthLink and Artisan Motion Pictures. Today, Garry and SEO Inc.’s highly skilled digital strategists develop proprietary technology and strategic digital marketing direction for Fortune 500 companies including, SC Johnson, McAfee,, Inc Magazine, IGN, Tacorri, LPL Financial, National Kidney Foundation, G4 TV, Fuel TV and Sony, just to name a few.