It’s a no-brain­er that val­i­da­tion plays a crit­i­cal role with any tag man­age­ment imple­men­ta­tion. In addi­tion to check­ing the ana­lyt­ics vari­ables for data accu­ra­cy on a page load or link click, it is equal­ly impor­tant to test that your code and tag rules exe­cute at the right time and in the right order. While there are many tools avail­able to help in this process I want­ed to share a few ways you can lever­age the brows­er con­sole to help you with val­i­da­tion in real-time. 

Use the “debug” mode in the DTM Switch

Much like the Adobe Debug­ger can help you see the out­put of an image request as the page loads, the DTM Switch is a Google Chrome or Fire­fox exten­sion that can be added direct­ly to the brows­er. Using the “debug” mode will send DTM activ­i­ty direct­ly to the con­sole. This tool is a “must have” for any DTM imple­men­ta­tion because it will show you exact­ly “what” your scripts are doing as the page loads or event activ­i­ty happens.

image
You will see the DTM Switch icon appear in the brows­er at the top right on any page where the DTM head­er 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 Fire­fox here

What’s great about this lit­tle util­i­ty is it’s built in debug­ging fea­ture. This allows you to see in the brows­er con­sole exact­ly when your rules are exe­cut­ed by DTM.

And com­bined with the script run­time data of the con­sole itself, the debug mode of the DTM switch can also help you trou­bleshoot the source of prob­lems that may hap­pen dur­ing the imple­men­ta­tion process.

Send your DTM script output directly to the browser console

Because each imple­men­ta­tion is cus­tom to some degree, this prob­a­bly means you will write scripts or func­tions to per­form cer­tain tasks that you’d like to val­i­date in real time. Some exam­ple use cas­es might include:

  • You have cus­tom Javascript code that dynam­i­cal­ly switch­es the report suite ID based on URL and you need to val­i­date the dynam­ic out­put as the page loads.
  • You have deployed a data lay­er in a JSON object on the page and need a quick way to val­i­date ele­ments with­out view­ing the page source.

Until recent­ly, using “console.log” was a very con­ve­nient way to send this data to the con­sole. 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­cal­ly in Inter­net Explorer.

For­tu­nate­ly, DTM has a built-in func­tion called _satellite.notify() that serves a sim­i­lar pur­pose as console.log and is cross-brows­er compatible. 

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

Func­tion Reference 
_satellite.notify(text_value,intensity_scale)

Exam­ple: Cus­tom Adobe Ana­lyt­ics Code

** Note that the default val­ue for inten­si­ty scale is 1 but can go as high as 5

Now when the script runs that con­tains the call to _satellite.notify( ) it will push the text direct­ly to the console.

Call _satellite.notify using a global wrapper function

If you’re like me, you’ll fre­quent­ly want to send the out­put from your scripts to the con­sole for val­i­da­tion and I could cer­tain­ly call _satellite.notify() every sin­gle time to do that. How­ev­er, I’m not a big fan of typ­ing the same func­tions and para­me­ters over and over in mul­ti­ple tags if I don’t have to. 

One way I cre­ate code effi­cien­cy when it comes to val­i­da­tion is to cre­ate a sin­gle func­tion that can be deployed as part of a glob­al page load rule at the top of the page and can then be ref­er­enced at any time by oth­er page rules.

For exam­ple, with most of my imple­men­ta­tions I deploy a “Glob­al Func­tions” page load rule that exe­cutes at the top of the page. This rule con­tains code and func­tions I use reg­u­lar­ly, includ­ing a func­tion I use for val­i­da­tion called dtm_notify().

dtm_notify() is sim­ply a wrap­per 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 glob­al rule, I can call it at any time to send script val­i­da­tion notes to the brows­er con­sole and I don’t have to call the long ver­sion with mul­ti­ple para­me­ters each time.

Exam­ple: Call­ing dtm_notify using Cus­tom Adobe Ana­lyt­ics Code 

Conclusion:

Val­i­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 sim­ple tools and tricks to make the process easy and effi­cient in real time.