How do I see javascript exceptions?

ben_hogan
Not applicable
ben_hogan
When a tag throws a javascript exception, Tealium seems to catch it. How do I see that error during development? Is there a switch to turn on debugging?
5 REPLIES 5

How do I see javascript exceptions?

Tealium Employee
You can add the following call to log output to the console. This is "IE Safe" because the utag.js will wrap the console.log call in a try-catch. utag.DB("error: ..."); To enable debugging, set this cookie: document.cookie = "utagdb=true"; The issue right now is a lot of code generated dynamically (i.e. Load Rule code) has an 'empty' catch block. We have a pending enhancement to put utag.DB calls in there as well. I think this is what you're looking for. For those empty catch blocks... you can use a Charles Proxy tool to replace files/content. You can swap out any "catch(e){}" with "catch(e){utag.DB(e)}" as a workaround. Not an easy workaround, but I think this may be what you're trying to do.

How do I see javascript exceptions?

fiann_ohagan
Employee Emeritus
fiann_ohagan
You can also use the browser developer tools. If you are asking about Javascript exceptions, you might feel confident to give this a try. In Chrome, you can find it on the View menu > Developer > Show Developer Tools. Then open the Sources tab, and click the pause button icon which is shown in my screenshot. It has three states: grey means inactive, purple means stop on "uncaught exceptions" and blue means "stop on all exceptions". Click it until it's blue, then reload the page. The Sources tab will show that code exception has stopped when there is an exception. You might well see some spurious errors which are part of the normal execution, just click the play button to carry on. When you get to the exception in your tag, you should see in the variables panel a message describing the error.

How do I see javascript exceptions?

andrew_gatlabay
New Member
andrew_gatlabay
Hi Ty, The exception logging enhancement would help out greatly. Do you know when this will become available? Debugging tag templates and extensions are pretty troublesome right now. Thanks, Drew
Highlighted

How do I see javascript exceptions?

Tealium Employee
Hi Drew, Thanks for the follow-up. The utag.js template version 4.35 (released today) has additional debugging for manual utag.view calls. For dynamic code, the utag.DB(e) should be in there for Load Rules very soon (next month? don't quote me on release dates..) We're also adding additional debugging output in each of our tag templates moving forward. Let your Account Manager know if you have a favorite template that would benefit. One more recommendation. Add this as a JS Extension scoped to your tag (or scope to multiple tags.) // output data layer snapshot at the point when this tag runs utag.DB(b); If you do a lot of data layer manipulation you may wish to add this as two Extensions. One that runs first and another that runs after all the others.

How do I see javascript exceptions?

andrew_gatlabay
New Member
andrew_gatlabay
Thanks for the information. We are pretty dependent on a few JS Extensions that implement Site Catalyst plugins for us. Currently, there is not any debug logging for JS Extensions. Well, at least with the Site Catalyst template tag. Extensions are run within a try/catch, but with an empty catch block. It would be great if the tag template would do that for us when it runs all the extensions.