How To Filter Ghost Referral Spam in Google Analytics

When you see a spammy link on your referral traffic or language, be weary of clicking on it. These sites are not linking to you, but rather appear on Google Analytics as click-bait or ghost referral spam for you to visit potentially harmful websites with malware or scams. The links are not actual traffic to your site.

Larger sites may not as noticeably suffer from an illegitimate traffic boost. For less trafficked websites, these spam traffic and language links can really skew your traffic, bounce rate, and session duration. Either way, it is beneficial to create a filter for spam.

To start, go to your Admin tab and then to View Settings for the account and make sure you have Bot Filtering selected.

Bot filtering

Google Analytics will then ‘Exclude all hits from known bots and spiders’. This is just the first step in blocking spam traffic because it only applies to known bots, not the new and emerging spam that occurs daily.

Referral Traffic Spam Filter

One way to filter out spam traffic is to include only traffic to the hostname.

Hostname Inclusion Filter

This hostname inclusion filter only lets traffic to pages on your actual web site through to your Analytics view. You can apply this filter in the Admin tab.

Admin bar

IMPORTANT: In the Admin tab, you’ll want to create a new view or apply these filters to an already filtered view. This way you will preserve at least one master account view that is unfiltered. Having an unfiltered view is important because you cannot undo filtered data. Create a new view in Google Analytics by clicking on Admin. Make sure you have selected the right account and property from the drop down menus. Once you have completed this step, click on view, select create new view, and give this view a name.

Once you are in the view that you want to filter. Select ‘Filters’ from the View tab and ‘+Add Filter’.

Hostname Inclusion

Next, ‘Create new Filter‘ and name the filter to note the inclusion of your hostnames.

Then, choose ‘Custom‘ Filter Type and ‘include‘.

Select ‘Hostname‘ from the Filter Field.

You are going to include only traffic to pages with your domain in the hostname and other trusted hostnames. The Filter Pattern is your main domain name and trusted domains in regular expression form with ‘|’ vertical bars in between the domain names.

NOTE: While this filter does not require regular maintenance, remember to update the Filter Pattern expression with any new domains that you add your Google Analytics tracking code to.

Once you have all of this in place, you may want to click ‘Verify this filter’ to see how the data would be affected by the filter for ghost spam. Filters can take time to apply to the data, but the Verifying preview shows real time results. Verifying is also a good idea because filtered data cannot be unfiltered.

If the Verify link comes back with a message that says “This filter would not have changed your data“, you might be looking at too short of a range of data. Try ‘Verifying with a larger set of data’.

Lastly, save!

Ghost Spam Referrer Filter

Another method of preventing crawler spam is to exclude known hacker sites from the view. To do this, create a filter in the view you want to apply it to. Remember these filters apply to future traffic from the date implemented, not historical data.

Once you’re in the desired View, click ‘Filters’ and then ‘+Add Filter’.

No ghost spam referrers

Next, ‘Create a new Filter’ and and name it to reflect Ghost Spam filter.

Then, choose ‘Custom‘ Filter Type and ‘exclude‘.

Select ‘Campaign Source‘ from the Filter Field. This is more effective than excluding by Referral due to spammers being able to alter the source and medium.

In the ‘Filter Pattern’, include all known spammer domains in regular expression form. Regular expression form means the domains are separated with ‘|’ vertical bars in between. Do not start or end the expression with a vertical bar ‘|’. There is a limit to the number of characters per expression. So, you may need to create multiple filters to include all known spammer domains for your site. There are extensive spam crawler lists that are constantly being updated available online. You can also update the domains yourself by regularly checking All Traffic to find new ghost spammers.

Then, you may want to click ‘Verify this filter’ to make sure the changes will apply as intended. Filters can take time to apply to the data, but the Verifying preview shows real time results. Verifying is also a good idea because filtered data cannot be unfiltered.

If the Verify link comes back with a message that says “This filter would not have changed your data“, you might be looking at too short of a range of data. Try ‘Verifying with a larger set of data’.

Save and watch the spam traffic disappear!

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *