It’s a no-brainer that vali­da­tion plays a crit­i­cal role with any tag manage­ment imple­men­ta­tion. In addi­tion to check­ing the analyt­ics vari­ables for data accu­racy on a page load or link click, it is equally impor­tant to test that your code and tag rules execute at the right time and in the right order. While there are many tools avail­able to help in this process I wanted to share a few ways you can lever­age the browser console to help you with vali­da­tion in real-time.

Use the “debug” mode in the DTM Switch

Much like the Adobe Debug­ger can help you see the output of an image request as the page loads, the DTM Switch is a Google Chrome or Firefox exten­sion that can be added directly to the browser. Using the “debug” mode will send DTM activ­ity directly to the console. This tool is a “must have” for any DTM imple­men­ta­tion because it will show you exactly “what” your scripts are doing as the page loads or event activ­ity happens.

image
You will see the DTM Switch icon appear in the browser at the top right on any page where the DTM header script is active

You can down­load the DTM Switch exten­sion for Google here

You can down­load the DTM Switch exten­sion for Firefox here

What’s great about this little utility is it’s built in debug­ging feature. This allows you to see in the browser console exactly when your rules are executed by DTM.

And combined with the script runtime data of the console itself, the debug mode of the DTM switch can also help you trou­bleshoot the source of prob­lems that may happen during the imple­men­ta­tion process.

Send your DTM script output directly to the browser console

Because each imple­men­ta­tion is custom to some degree, this prob­a­bly means you will write scripts or func­tions to perform certain tasks that you’d like to vali­date in real time. Some example use cases might include:

  • You have custom Javascript code that dynam­i­cally switches the report suite ID based on URL and you need to vali­date the dynamic output as the page loads.
  • You have deployed a data layer in a JSON object on the page and need a quick way to vali­date elements without viewing the page source.

Until recently, using “console.log” was a very conve­nient way to send this data to the console. The down­side to using this method is it does not work the same in all browsers and may throw errors or affect the user expe­ri­ence — specif­i­cally in Inter­net Explorer.

Fortu­nately, DTM has a built-in func­tion called _satellite.notify() that serves a similar purpose as console.log and is cross-browser compat­i­ble.

This func­tion requires 2 para­me­ters and can be called as part of any script you deploy in DTM.

Func­tion Refer­ence
_satellite.notify(text_value,intensity_scale)

Example: Custom Adobe Analyt­ics Code

** Note that the default value for inten­sity scale is 1 but can go as high as 5

Now when the script runs that contains the call to _satellite.notify( ) it will push the text directly to the console.

Call _satellite.notify using a global wrapper function

If you’re like me, you’ll frequently want to send the output from your scripts to the console for vali­da­tion and I could certainly call _satellite.notify() every single time to do that. However, I’m not a big fan of typing the same func­tions and para­me­ters over and over in multi­ple tags if I don’t have to.

One way I create code effi­ciency when it comes to vali­da­tion is to create a single func­tion that can be deployed as part of a global page load rule at the top of the page and can then be refer­enced at any time by other page rules.

For example, with most of my imple­men­ta­tions I deploy a “Global Func­tions” page load rule that executes at the top of the page. This rule contains code and func­tions I use regu­larly, includ­ing a func­tion I use for vali­da­tion called dtm_notify().

dtm_notify() is simply a wrapper that sends the text para­me­ter back to _satellite.notify().

Here’s the function:

function dtm_notify(text)
{
    _satellite.notify(text,1);
    return true;
}

And now with this func­tion deployed as part of a global rule, I can call it at any time to send script vali­da­tion notes to the browser console and I don’t have to call the long version with multi­ple para­me­ters each time.

Example: Calling dtm_notify using Custom Adobe Analyt­ics Code

Conclusion:

Vali­dat­ing your scripts and tag rules is crit­i­cal to any DTM imple­men­ta­tion. It’s great to have a few simple tools and tricks to make the process easy and effi­cient in real time.