How to protect your Google Analytics data from Spam

If you’re using Google Analytics to collect data about your website, it’s really important that you ensure all the data you’re collecting is accurate and comes from your website.

Google Analytics works by installing a tracking snippet in the code of each page on your website. This snippet contains javascript code that sends data about your site into Google Analytics. It’s a pretty basic process, but it isn’t very secure.

Anyone can browse the page source on your website and see what your Google Analytics snippet looks like – and there’s nothing stopping them from putting that snippet on their website either. This isn’t something you usually need to worry about from competitors or people you know – but spammers often use this technique to add data to your Google Analytics account that has nothing to do with your website.

If someone else installs your Google Analytics tracking snippet on their website, all of the data from their site will flow into your account as well. To protect yourself from this, you need to create a filter that excludes all data that doesn’t come from your website’s domain.

To do that, log into your account, and click the “Admin” tab, then click on “Filters” under your view. That will bring you to the filters page, where you want to create a new filter. That’s what you see here below –

Google Analytics Create Filter

Give your filter a descriptive name, then create a Custom filter to Include Hostname. For filter pattern, Google provides some advice about how to set it up (pictured below), but generally if you’re tracking a single domain, you can put a pattern like the one you see above on our website.

Google Analytics Hostname Filter Guidelines

Once you’ve done that, hit save and you’re all set! Of course, your filter will only apply to new data inserted into your Google Analytics account – so keep that in mind if you see any immediate metric fluctuations – it’s all your website data now – nothing else.


Sign Up for Product Updates

  • This field is for validation purposes and should be left unchanged.

About Us

We build productivity tools and integrated data solutions for marketers using WordPress.

Born out of agency work, we saw an opportunity to build better tools for marketers and developers.

Who We Are

Tom Hall
Tim Howe
Front-End Development
Matt Harrison
Back-End Development