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.
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 –
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.
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.