How to Block Referrer Spam

5 Methods: Campaign Source Exclude Filter  |  Campaign Referral Path Exclude Filter  |  .htaccess File | Filter Language Spam  | Exclude All Hits From Known Bots and Spiders

Referrer spam is becoming a huge problem for many webmasters, website owners, and those who provide website services. It can ruin you website’s Google Analytics data and be hard to ignore. Referrer spam that employs bots and crawlers can also use bandwidth and cause confusion for new website owners. this is why many webmasters chose to block referrer spam.

referrer spam

The information on this page is design to help you block referrer spam in Google Analytics and stop unwanted bots and spiders from messing with your website’s data, bandwidth, and more.

What is Referrer Spam?

Referrer spam is a form of spam indexing aimed at website analytics data we discovered a few years ago. It is designed to create repeated site requests using a referral URL to the website the spammer wishes to promote. The benefits that referral spammers have with this 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.

Referrer spam is primarily designed to acquire website traffic to the websites they advertise with the referrer spam tactic. There are many well known referrer spam spam websites such as lifehacĸer.com, semalt.com, and o-o-4-o-o.com.

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

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.

.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]

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.

Exclude All Hits From Known 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

http://Botcrawl.com

Sean Doyle is an engineer from Los Angeles, California. Sean's primary focuses include Internet Security, Web Spam, and Online Marketing.

Comment ( 1 )

  1. Replydigitalgirlie
    Ugh! Novice here struggling to understand instructions. I have a list of exclusions I need to put in place and I'm trying to understand which filter setting I choose. For example, I followed the directions for compliance-brian.xyz article that you published. In that post, you say to chose Campaign Source. Was wondering why I wouldn't choose Campaign Referral Target URL instead. All my spam entries in analytics are to URLs like this one below which Google Analytics labels "Page Title." motherboard.vice.com/read/this-pro-trump-russian-is-spamming-google-analytics I have one that is not a URL. It simple reads Vitaly Rules Google. Do I also select Campaign Source or should I choose something else? Any help you or anyone else could throw my way would be most appreciated.