Filtering Out Your Hits From Google Analytics

The best way for Google Analytics teams and consultants to filter out their own data.

The data in Google Analytics is only useful if it’s clean. And since you can’t overwrite GA’s data, you have to do everything you can to make sure that it’s clean upfront. One of the easiest ways to dirty your data is to include internal traffic from the GA implementation team or consultant. Because they will likely submit a lot of conversions, events, and pageviews while testing the implementation, they can wildly skew your results.

The standard way to filter out traffic like this is to set up an IP Address filter. However, there are a couple of issues with this.

First, most internet service providers now use dynamic IP addresses. Because your IP address constantly changes, you can’t create a GA filter based on it anymore.

Two, and this is especially important for GA consultants like me, people are working from home/coffee shops/bouldering gyms/airplanes/air b and bs/different co-working spaces, maybe all in a single day. Obviously, you can’t reasonably expect your GA team to add all of these IPs.

Fortunately, there is an additional option that works especially well for teams using Google Tag Manager.

All you have to do is tack “-INTERNAL” to the end of the page title using Google Tag Manager DEBUG mode and create a custom filter in GA to filter out those hits.

Here’s how to do it.

Note: Because this only works for users with Google Tag Manager preview mode open, it won’t replace company-wide IP filters YET. I’m working on a Chrome Extension that will solve that exact problem. Sign up to be notified when it’s ready.

Step One - Change the Page Title with GTM

Download the Tag Manager recipe here.

When you’re implementing GA using Google Tag Manager, you’re almost certainly using GTM’s preview mode to debug your implementation. It turns out that GTM has a little used but VERY USEFUL built-in variable call Debug Mode that will be true when in preview mode and false when not. Enable it by going to Variables > Configure and selecting Debug Mode like so:

image alt text

Now create a new Page Title DEBUG Mode Variable using this custom template (read how to install custom templates here) that returns the normal page title when Debug Mode is false, and return Page Title-INTERNAL when it’s true.

image alt text

Alternatively, you could create a Custom Javascript variable that does the same thing as the custom template like so (though I recommend using the template):

image alt text

Finally, we just have to replace the default Google Analytics page title with our new variable. To do so, select your Google Analytics Settings variable and set a new field for title to our Page Title DEBUG variable.

image alt text

Now every hit that comes from a user who has the Google Tag Manager preview mode enabled will have “-INTERNAL” tacked onto the page title.

image alt text

We can use that to create our filter in Google Analytics.

Step Two - Create the Page Title Filter in GA

Now that we have our INTERNAL page title flagging hits from GTM preview mode in Google Analytics for us, filtering these hits out is a breeze.

Just select the view you want to filter internal traffic out of (you should always have a least three views, one without any filters, one for testing, and one “master” view that you actually use for analysis). Then click Admin > Filters > Add Filter and create a filter that looks like this:

image alt text

That’s it. You’re now filtering out your GTM preview hits from your view. I personally set this up first, before doing any GA work, and just leave preview mode on whenever I’m working on any of my client’s sites so my traffic is always flagged properly.

Conclusion

The Page Title method described above has several advantages over just filtering IP addresses. First, it will work with dynamic IPs and remote workers (like me!).

Second, because it adjusts the page title, even if your filter breaks, your internal traffic will still be flagged as such in GA and you can easily filter it out with a custom segment.

Finally, you could, of course, use the same method but with a custom dimension for “internal traffic”.But using the built-in page title doesn’t waste custom dimensions on filtering out internal traffic.

One more pro-tip for Google Analytics implementers and consultants. You can create an “Internal-Only” view with the exact reverse of the filter above like so:

image alt text

The “Internal-Only” view is particularly useful if you’re setting up or troubleshooting Google Analytics on a site that has a lot of traffic.

Note: Because this only works for users with Google Tag Manager preview mode open, it won’t replace company-wide IP filters YET. I’m working on a Chrome Extension that will solve that exact problem. Sign up to be notified when it’s ready.

comments powered by Disqus