Site icon Return

How To Block Donald Trump Spam From Google Analytics

If you’re reading this article, you’ve more than likely seen a spike in referral traffic to your site recently from sites such as reddit.com, lifehacker.com and thenextweb.com – however, all is not what it seems and your site isn’t as popular as you might think, this is just another example of ghost spam.

Some Russian has decided to mess about with your stats in some sort of warped tribute to the recently elected Donald Trump, as demonstrated by the spam’s language setting which is set to:

Secret.ɢoogle.com You are invited! Enter only with this ticket URL. Copy it. Vote for Trump!

You can find out more about what this spam is specifically all about by reading this article on, funnily enough, thenextweb.com.

The bad news, to a degree, is that you can’t stop this from happening and your stats will be forever skewed.

The good news is you can set up a filter to block this traffic moving forward, and create a segment to view your historical stats with the spam removed.

 

Setting Up A Filter

This will block all such spam moving forward – but do be careful setting a filter up, as you could inadvertently block everything if you do this wrong.

In Analytics Admin, Go To Account -> All Filters -> Add Filter

Give your filter a relevant name, such as “Donald Trump Spam Wall”

Set Filter Type To “Custom”

Select Exclude, set Filter Field to Language Settings.

Set the Filter Pattern to:
s[^s]*s|.{15,}|.|,

(trust me, that works)

Apply to your selected views and click save.

 

Setting Up A Segment

This will not remove the spam from your account data, but will allow you to view your stats retrospectively with the referrals removed.  These are preferable to filters in that you can test and edit until you are certain you are only excluding / including the relevant traffic (so maybe test here before setting up the filter above) – but you do need to remember to apply this filter every time you view your GA data.

Within your GA account, click “Add Segment”

Click the red button “+ NEW SEGMENT”

Again, give it a relevant “Segment Name”

Under “Advanced”, Select “Conditions”.

Alongside “Filter”, Select “Sessions” and “Exclude”.

From the dropdowns, select “Language” and “matches regex”, and set the pattern to:

s[^s]*s|.{15,}|.|,

To verify this works, you will see to the right how much of the referral traffic this will block:

Click Save, and you will be able to compare your original data alongside your data with the spam blocked out:

And that’s it.

We have a pre-configured segment that blocks out all known spam in the last 12 months or so which can be downloaded here.

If you need any help setting this up or have any questions relating to Google Analytics spam, contact us now or leave a comment below.