Best practices

Gold Contributor
Gold Contributor

What are the best practices to define utag_data, utag.js, utag.link, utag.view; from the below mentioned options?
1) All the tags (looping conditions) in a JS file.
2) All the tags (looping conditions) in a JSP file.
3) utag_data / utag.js directly on the page templates, utag.view / utag.link looping conditions in a separate JS file.
The reason for this query is to avoid any hassles on the load of the utag.js.

4 REPLIES 4
Employee Emeritus
Hey Manish, Thanks for the question. I'm hoping to get a little more detail around what you are asking with #1 and #2. Are you asking how to define the utag_data object, the utag.js file and utag.link/view methods if you were to define them an external JavaScript or JSP file, instead of loading them directly in the HTML of the page? Also, what is meant by "looping conditions"? I know you had a question previously about events getting called multiple times due to how the extension was configured. Is this what you were referring to? Thanks
Gold Contributor
Gold Contributor
Yes Jared, I want to know what is best way to define utag.js and utag_data.â I had suggested my developer to add utag_data and utag.js on each template/pages, don't call this from any any jsp file. And for all utag.link/view conditions create .js file to include all jquery/other conditions in a single file. Just want to know your thoughts on this if this is the best practice so that avoid any load issue with utag.js.

Best practices

Employee Emeritus

Manish,

In terms of loading the utag_data object (UDO), utag.js and utag.view there are some basic guidelines to follow:

1) Always load the UDO before referencing the utag.js file. This will ensure all your data points are populated before trying to access them in tags, extensions load rules, etc.

2) As a best practice always load the utag.js file directly on your pages in the HTML source. We do not recommend altering the utag.js script provided in the code center when placing it on your pages. For example, dynamically populating the environment based on a variable from the page or using the file reference to load the utag.js contents later in a separate file.

We've seen this where a client will try to get "fancy" in loading the utag.js file, but one pieces of their code will break and the utag.js file is not loaded. In that case, none of their tags fire and all tracking is lost. And because Tealium has no control of the page code and referencing the utag.js, all tracking is broken until the client's dev team can update their code, which could be awhile. :)

So always try to paste exactly what we give you into the HTML of each page.

3) After page load, use utag.view or utag.link to trigger post page load events. The utag.js file should not be "re-loaded" after the initial page load. There should only be one instance of the utag.js on each page.

4) It is fine loading utag.view/utag.link functions in external js or jsp files, and it does not have to be in the same file. Many clients do this, and each one has their own way of loading these functions. These functions can load at any time; however, these should not get triggered until after the utag.js file has loaded. If you try to call utag.view before the utag.js file has loaded, the function will error and the event will not get tracked.

There really isn't a "best practice" way of triggering utag.view or utag.link. Since every site is coded differently it is difficult advise how these functions should be triggered. The coding aspect of triggering these is usually left up to the client's developers to use their discretion.

5) Do not call utag.view or utag.link on page load. On page load, when the utag.js loads, Tealium will automatically send page view server calls to the tags assigned to that page. Because of this, there is no reason to call utag.view after the utag.js has loaded to send initial page load data.

It is completely fine to trigger utag.view post page load to track such things as modal popups, slideshow changes, etc.

Hope this helps answer some of your questions

Cheers!

Best practices

Gold Contributor
Gold Contributor
Thanks Jared, this is really helpful
Public