Google Analytics Quick Tip: Prevent Tracking Code Theft

  • follow us in feedly
Published December 5, 2013 by Brad Knutson
Google Analytics Quick Tip: Prevent Tracking Code Theft

For the third time in less than a month, some hooligan has stolen my Google Analytics tracking code! I checked my Google Analytics reports today, as I do frequently, to find an increase in traffic. At first, I was excited to see where this new traffic was coming from! There was a bunch of new referrals, maybe one of my articles got picked up somewhere and there was a bunch of referral traffic coming in.

Unfortunately that wasn’t the case. The increase in traffic was going to a bunch of landing pages that I knew were not part of my site, and being referred by a bunch of sites that wouldn’t be linking to me in the first place. I had seen this before (twice) and I knew immediately what was going on.

Stop Stealing My Google Analytics Tracking Code!

Someone had stolen my Google Analytics tracking code…again!

What likely happened was that someone saw one of my posts where I posted a code or markup intensive example, so they viewed the source of the page and copied everything. When they pasted the code onto their own website, they must have not noticed my Google Analytics tracking code was left behind, or they didn’t know any better.

It’s partially my fault though, as I didn’t have a filter set up to prevent this data from polluting my Google Analytics reports. I take the blame for that…

So today, I’d like to show you a really easy filter to implement that will prevent this from ever happening to you!

Setting Up The Google Analytics Filter

Log into your Google Analytics account, and click the Admin button, usually on the right side of the navigation bar.

Select the Account, Property, Profile that you want the filter to be applied to. Note that if you have multiple Properties and Profiles you may want to add the filter to many or all of them – it’s up to you.

Click on the Filters link in the Profile column.

Google Analytics - Setting Up a Filter

Next, we’ll create our custom filter.

  1. Name the filter something memorable, I chose Exclude External but Prevent Tracking Code Theives would also be appropriate.
  2. Leave the Filter Type at it’s default of Predefined Filter.
  3. Set the next three drop-downs to Include only, traffic to the hostname, and that contain.
  4. In the Hostname field, enter your domain name – leaving out http:// and www. – just enter (replacing example with your domain name). Don’t worry about subdomains.
  5. Save it!

Google Analytics Filter

Head over to the reporting side of Google Analytics and monitor your Real Time traffic for a few minutes to make sure that you are still tracking visitors. It would be tragic to accidentally set the filter to Exclude when you meant Include…so make sure that you set it up right!

Monitor your traffic over the next few days to make sure everything is normal, then you won’t have to worry about your tracking code being stolen ever again!

The following two tabs change content below.
Founder at Inbounderish
Brad Knutson is a Web Developer in the Twin Cities area of Minnesota. He has experience working with WordPress and Drupal, and also has an interest in SEO and Inbound Marketing.

Keep Up-to-Date



See a complete list of topics discussed in blog posts here.

Check These Out

Get 2 Weeks Free! Sign Up Today! Premium Managed WordPress Hosting Genesis Framework for WordPress SEO is complex. Tools should be simple. Thesis Theme for WordPress:  Options Galore and a Helpful Support Community

3 thoughts on “Google Analytics Quick Tip: Prevent Tracking Code Theft

    1. Brad Knutson Post author

      To be honest, I didn’t know it was possible either! I just assumed that Google would filter out traffic data if it was on a completely different domain (why else would they have you enter your domain in the first place?!) but you live and learn I guess :)

  1. jubby

    Any way to stop others from using your Google Analytics account number? The filter works well, but I wish I didn’t even have to do that. What’s the point of verifying your domain if anyone can just use your account number? Seems like Google would have something in place to prevent this.


Share Your Thoughts

Your email address will not be shown.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">