How to Block Spam from Countries in Google Analytics
Google analytics is great, but it often is spammed with fake data into reports that will skew your traffic reporting. If you have ad networks like Adthrive or Mediavine, then this can mess up your RPM calculation. Please note that if you use an ad network, RPM calculations are based on these numbers, but they do not affect the actual revenue paid out. It’s just reporting data for your benefit.
At the time of this post, there is a bunch of analytics spam coming from two countries, Czechia and Seychelles. This is pure analytics spam, so it’s not real traffic hitting your site. Your host can’t block traffic that doesn’t actually go to the server.
In this post, I’m going to show you a quick way to filter out this data in Google analytics. You can do something similar in CloudFlare, but this also will affect real readers from these countries. The Google analytics filter is a better option and much easier.
This process is very easy to do and takes less than 5 minutes.
How to Check for Spam
In your analytics account, go into Audience > Geo > Location and check the data coming from countries.
The image below shows what it would look like.
If you have a bunch of data like from above that is abnormal, then it’s time to filter out these countries. This does not pull out the data already in the reports, but this will stop it from going into the report going forward.
How to Setup a Filter in Analytics
The next step is easy. Go to the bottom left and click admin (or it might be a cogwheel) to get to the admin panel.
Once in the admin view, you will see three columns. You will be adding a filter into the view, which is the third column (to the right).
When you go to the admin, it will open up the property and default view you use in the reports, so you shouldn’t have to change it.
Once in the filter setup, click “Add Filter” red button to create this simple filter.
Create the Custom Filter
You will need to create a custom filter now just for the countries that you want to block. You can add/remove countries as you see fit as the analytics spam changes. You can also turn off the filter at any time once this spam stops.
In the Filter name, you can call it whatever you want. Doesn’t matter as this is just for your information. In this guide, I called it “Country Spam Block“.
The filter type will be “Custom“
Radio button for “Exclude” will default and you keep that.
Filter field should be “Country“
Filter pattern will be the countries you want to block. You separate each one with a pipe “|”
So in this instance, it would be: Czechia|Seychelles
Under Filter verification, click verify and it should show you the data that would have been excluded if the filter was in place. If it picks data up, then the filter is correct and it will filter out information going forward. If you don’t have enough data, then the filter might not validate, but it should still work.
Then click “Save”
Once you click save, you are all set.
That’s all you have to do.
Thank you, Grayson. That was easy!
Thanks Grayson. Very helpful. Will this block ALL the traffic from the blocked countries or just the bot traffic? And how do we know when it’s safe to unblock it? Thanks
This doesn’t block any traffic from the actual site. This just stripes it out of reporting. This will strip all visits from those countries out of the reports.