What is referrer spam and how do I block it?

Referrer spam


Learn what referrer spam is and how to block unwanted referral traffic and bots using your .htaccess file and in Google Analytics.

Links on this page

What is referrer spam?


Referrer spam is a form of spam indexing aimed at website analytics data that has been around for a few years. Referrer spam is designed to create repeated site requests using a referral URL of the website the spammer is promoting (or of a URL that will forward to the site they are promoting). The benefits that referral spammers have with this blackhat SEO tactic is that it will help them advertise the website they want people to visit and it will also improve the spammers search engine ranking by potentially creating backlinks.

referrer spam

Referrer spam is primarily designed to obtain new visitors and website traffic to the sites they are promoting. When a webmaster or website owner notices unusual referral traffic in their data they might become curious and visit the URL. The sites promoted by referrer spam usually have something to do with online marketing or services that website owners might find appealing.

Over the years, referrer spam indexing has become a big problem for many webmasters, website owners, and those who provide website services. It can ruin your website’s Google Analytics data and be hard to ignore. For example, a referrer spam site usually appears to visit one page on your site multiple times which will manufacture a 100% bounce rate. If you want to know how your site is performing, this can cause an issue. Referrer spam that employs bots and crawlers can be an even bigger problem because they can use bandwidth andc negatively affect your site’s performance.

How to make a campaign source exclude filter


Create an exclude filter if you do not wish to receive referral traffic in your Google Analytics data from specific URLs. To block a referral path use the Campaign Referral Path Exclude Filter below.

1. Open your Google Analytics account and go to the Admin tab > Click Filters on the right side in the VIEW section.

how to block referrer spam

2. Click the + ADD FILTER button to create a new exclude filter.

3. Add something you can easily remember as the Filter Name such as “Referrer Spam Filter.”

4. Select the Custom Filter Type.

block referrer spam google analytics

5. In Filter Field, find and select Campaign Source in the list. In the Filter Pattern text box, add the referrer spam URL you want to blcok and click the blue Save button on the bottom of the webpage. To add multiple URLs to the same filter you can make a Filter Pattern similar to this with a | between each URL: Example.com | Example.com

How to make a campaign referral path exclude filter


1. Open your Google Analytics account and go to the Admin tab > Click Filters on the right side in the VIEW section.

2. Click the + ADD FILTER button to create a new exclude filter.

3. Add something you can easily remember as the Filter Name such as “Referrer Spam Filter.”

4. Select the Custom Filter Type.

5. In Filter Field, find and select Campaign Referral Path in the list. In the Filter Pattern text box, add a partial string of the referrer spam URL that you want to block and click the blue Save button on the bottom of the webpage.

How to block referrer spam using .htaccess file


To block referrer spam at the source using your .htacess file edit the code below to block the specific URL you want to block and add the code to your .htaccess file. To block a specific referrer spam website replace example.com with the URL you want to block.

RewriteCond %{HTTP_REFERER} example.com [NC]
RewriteCond %{HTTP_REFERER} example.com
RewriteRule .* - [F]

Alternative .htaccess File

RewriteEngine On
RewriteCond %{HTTP_REFERER} example\.com [NC]
RewriteRule .* – [F]

How to filter language spam


Filter language spam in Google Analytics to get rid of spam using the language dimension.

1. Open your Google Analytics account and go to the Admin tab.

2. In the “View” column select Filters and then click + Add Filter.

3. Add a Filter Name: Language Spam (or something you can easily remember).

4. Go to: Filter Type > Custom > Exclude

5. Select Filter FieldLanguage settings

6. Add a Filter Pattern\s[^s]*\s|.{15,}|\.|,

7. Click on the blue text that says Verify this filter to see a preview table of how this filter will work in your account. You should only see language spam on the left side of the table: filter-verification-language-spam

8. After you verify the filter click the Save button on the bottom of the page.

How to exclude hits from bots and spiders


Exclude all hits from known bots and spiders in Google Analytics to block bad-bot and spider traffic.

1. Open your Google Analytics account and go to the Admin tab

2. In the “View” section select the account you want to use or ensure that the account name is visible.

3. Click View Settings in the “View” section and scroll down to the Bot Filtering area.

4. In the Bot Filtering area check the box that says Exclude all hits from known bots and spiders and click the blue Save button below. This will block known bots in Google Analytics.

Sean Doyle

Sean Doyle is an experienced tech author with experience in cybersecurity, privacy, malware, and more. He has written for numerous online publications.