When you have multiple people working on a website, you don’t want their visits polluting your Google Analytics (GA) data. There are many ways to combat this, like IP filters and extension based solutions, but none of them are foolproof. The following solution isn’t the unicorn you’re looking for as well but will work nicely together with the previously mentioned solutions.

This solution will filter out all traffic that is using the Google Tag Manager Debug mode. We can be certain these are hits that we don’t want to include in GA since these are all from people working on the website. This method works by filtering the GTM version number as it defaults to “QUICK_PREVIEW” when debugging a website. The following steps will guide you through the steps adding it to your website.

Step 1: Adding a custom dimension.

First, we are going to add a new custom dimension on hit level in Google Analytics. You can do this by going to Google Analytics > Admin. Under property, click Custom Definitions and go to Custom Dimensions.

Here you can create a new custom dimension – give it a good naming convention; we used “GTM – Version number”. Hit save and write down the index number of the custom dimension you have just created, we will need it later on.

Step 2: Configuring the variable.

Next up, log in to GTM and navigate to the variable section. We need to enable an already built-in variable; we can do this by clicking the “configure” button.

Head down to the section called “utilities” and select the container version. By enabling the variable we can use it to populate the custom dimension we created earlier.

Step 3: Populating the custom dimension.

Scroll a bit down and select “Google Analytics settings” in the user-defined variables section. Click on more settings and open the custom dimension tab. For the index value, we are going to use the number we wrote down earlier. For the dimension value, we are going to use the container version variable. You write this down as {{Container Version}}.

Step 4: Filtering the QUICK_PREVIEW hits.

We’re almost done! Head back to GA and go to the filters menu. We are going to add a new filter. For the filter name we’ve chosen for “exclude – gtm preview”. Make this as descriptive as you’d like. For the filter type, we’ve chosen “custom” and in here we are going to exclude based upon our “GTM – version number”. You can select this from the drop-down menu. As Filter Pattern you need to use “QUICK_PREVIEW”. Hit save and you’re all done! From now on debug hits from GTM won’t populate your GA anymore.

As an added bonus you can now select the Version Number as a second dimension for all GA hits. This can make it easier to debug on which container version things went wrong with your tag implementation!

Leave a Reply