Quick Tip: Debugging for the Masses

This article describes a method for setting up triggers (A.K.A load rules, A.K.A conditions) using a querystring parameter and a cookie. This is a useful method for testing a tag before it goes to production.

The Dilemma

I recently ran into a situation where a variety of people across a few agencies needed to test a tag in production, but they didn’t want the tag active to the public at large. While most Tag Management systems provide tools for testing, the drawback when dealing with such a wide variety of people is that you have to explain how the testing tools work. This may include descriptions of tools to download, extensions to install, or other processes that are perhaps not intuitive to the non-technical user.

The Solution

The solution I came up with is:

  1. Instruct the user to go to the site with a particular querystring parameter added. For example, if the site is www.bacontoday.com/, the user would append a parameter as follows: www.bacontoday.com/?baconDebug=true
  2. In GTM, I created a custom Javascript variable that looks for the baconDebug querystring parameter. If it exists and is set to true I set a session cookie called baconDebug – Set Cookie with its value. The code for my custom variable is:

    function() {
    if (document.location.href.indexOf("baconDebug") > -1){
    document.cookie = "baconDebug=true";
    {{Bacon Debug Cookie}} = "true"
    }
    return "true";
    }
  3. I created a variable that stores the cookie value called Bacon Debug Cookie.

  4. Cookie Variable Config

  5. I created a trigger called Bacon Debug with the condition Bacon Debug Cookie is set to true.


    Trigger Config

  6. I applied the trigger to my tag.

  7. Load Rule Applied

The method described above was done in Google Tag Manager, but a similar approach would work for Tealium, Ensighten, and various other tag management systems.

This approach allows users with the cookie to view the tag without having to go use any of the testing tools Tag Management Systems might provide.

Join the Conversation...

Leave a Reply

Your email address will not be published. Required fields are marked *

Are You Ready to Start?

Contact us today to get an audit of your site!

Get an Audit