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.
Solved! Go to Solution.
01-16-2014 09:55 AM - last edited on 10-05-2015 01:10 PM by kathleen_jo
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