In my last post, I wrote an article, "How to block referrer spam". Though the post had a very good response among my readers, the method is very difficult to perform because you need to create a new property.
So, this time, we introduce a new method. This method has the following merits:
- You don't have to create a new property or view.
- You only have to apply one filter to the view.
- You can expect great effectiveness.( I have had only 23 sessions of referrer spam in 6 months.)
So, I recommend you to try this method.
This method assumes that you meet the following conditions;
- You can customize tracking codes of Google Analytics.
- You have Manage Users permission for the property you are working on.
- You use Universal Analytics(new version of Google Analytics).
- You have not used up all your custom dimensions. ( if you have created 20 custom dimensions, you cannot add new ones, unless you are a Premium User.)
I think this method is feasible in almost all cases, since these conditions are not difficult to meet.
First, you add a custom dimension to the property. The name might be something like "Referrer Spam Filter" and the scope might be "Session".
For procedures for adding custom dimension to a property, refer to Google Analytics official help "Create and edit custom dimensions and metrics".
As a next step, you edit the tracking code and assign a value to the custom dimension.
For how to edit tracking codes, refer to Google Analytics official help, "Custom dimension & metrics", paragraph "Collection".
Normally, you assign an appropriate value for each user or session. But in this case, you assign a fully fixed value. And the value can be any string.
ga('set', 'dimension1', 'SEM Technology Referrer Spam Filter');
If you use Google Tag Manager, set this value in custom dimension when you fire Google Analytics tracking tags.
As a last step, you add a filter to the View on the Admin page The filter configuration might be as follows:
|filter name||Block Referrer Spam|
|filter type||custom, match|
|filter field||Referrer Spam Filter|
|filter pattern||SEM Technology Referrer Spam Filter|
- Note1: filter name may be changed.
- Note2: filter field should be the name of custom dimension created in Step1.
- Note3: filter pattern should be the value assigned to custom dimension in Step2.
Most instances of Referrer Spam do not actually visit your web site. In reality, they generate randomized tracking ID’s and send them to Google Analytics by Measurement Protocol. They have prima facie genuine parameters, like page path, referer, browser, language and others, so they cannot be filtered correctly based on parameters. But by using custom dimension, you can identify correct tracking data, because correct tracking data contains the fixed string, whereas referrer spam does NOT.
As a conclusion, some instances of referrer spam still remain even with this method. The following instances of referrer spam have been found on this site:
These instances of referrer spam actually visited this web site. I confirmed it on my web server logs.
It is difficult to block this type of referrer spam which actually visits your site. But this method can block almost all instances of referrer spam. In fact, this site has had only 23 sessions of referrer spam in 6 months.
If you implement Google Analytics tracking code by Google Tag Manager, you can check by referrer host name if the referrer host which actually visited your site is a referrer spammer.
And, you can configure it so that you stop firing Google Analytics tracking code or assign a different value in custom dimension if the referrer host is a referrer spammer.
More specifically, if you set variables and rules as follows, you can control conditions for firing Google Analytics tags.
Since the filter is shown as a lookup table, you can easily grasp the filter configuration even when the number of referrer spammers has increased. (Unfortunately, it is difficult to tackle different varieties of referrer spam, because the lookup table does not accept regular expression.)
If you are thinking about anti-referrer spam measures and you don't want to create many filters, I recommend you this method.