- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
06-15-2015 01:21 AM - last edited on 10-08-2015 09:27 AM by kathleen_jo
We currently have the challenge that on our pages it can not be assured that all data used for our UDO is ready before loading the utag-script. We have pages where content is loaded dynamically and therefore certain UDO-parameters are only ready after a certain time.
This is the reason I currently tend towards the approach to only use utag.view() for all pages, regardless of the type of the page (to have an easier general solution).
My post is more a question about best practices, experiences of others.
Does anybody have experience on integrating Tealium on "mixed" pages? Are there any concerns? Issues? Points to be aware of?
Any feedback is welcome!
06-16-2015 09:13 AM - last edited on 10-08-2015 09:28 AM by kathleen_jo
Hi Martin,
As long as you suppress the initial pageview that utag.js generates (this is the main thing to be aware of), you just need to trigger utag.view() after you know the UDO is complete. This works fine for our clients that are on Angular-style constructed pages.
06-16-2015 11:34 AM - edited 10-08-2015 09:38 AM
Martin
I agree with Son, however another approach is to first build up utag_data and then only after utag_data has been built would the code call utag.js. You can see some sample code in my previous post. (I uploaded the code as a file because it does not display cleanly in comments)
06-17-2015 12:39 AM - last edited on 10-08-2015 09:39 AM by kathleen_jo
Hi Son,
hi Brian,
Thanks for your answers. The approach we implemented is more or less what you described. I just wondered if others might have experienced some drawbacks using this approach, but if not, I'm happy with that!
06-17-2015 09:26 AM
06-23-2015 01:59 AM - last edited on 10-08-2015 09:42 AM by kathleen_jo
This is exactly an issue I also had in mind. :-)
The approach I am following right now looks like this:
- Make a distinction between "Static Rendering" and "Dynamic Rendering"
- "Static Rendering": all necessary data for the datalayer is available BEFORE loading the utag script. In this case, developers will fill up utag_data.
- "Dynamic Rendering": it can not be known if data for the datalayer is available at the loading time of utag.js. In this case, prepare data for the datalayer in a different JS object (i.e. var udo_dyn), and as soon as all data is available and utag script is loaded, call utag.view(udo_dyn)
06-23-2015 12:24 PM - edited 10-08-2015 09:43 AM
Martin
With the "Dynamic Rendering" I think you will also want to use
//suppress the initial pageview generated by loading utag.js
window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};
window.utag_cfg_ovrd.noview = true;
Then after this object is established, load the utag.js library.
Then after you have loaded all your udo_dyn, call utag.view(udo_dyn)
See: Where can I find a list of utag_cfg_ovrd possible flags?
10-08-2015 09:38 AM - edited 11-23-2015 02:55 PM
With the following code, you do not need to supress the utag.view call as you will not be calling utag.js until after all of your async files have been executed.
/* A Tealium best practice is to only call utag.js after utag_data is available. In this example we are building the utag_data dynamically based on data coming back from many async calls to external javaScript files. We do not want to call utag.js until all of the extenal async calls are complete. To accomplish this we have an object called utagDataReady which we build up each time a javascript file completes. Then we check if all the async calls are complete and if they are then we load utag.js The function tryToCallUtag is called after each async file processes. This code has not been tested and has been written for example purposes only. */ function tryToCallUtag(methodName){ window.utagDataReady = window.utagDataReady || {}; utagDataReady[methodName] = true; if(utagDataReady["someMethodName"] && utagDataReady["someMethodName2"] && utagDataReady["someMethodName3"]){ (function(a,b,c,d){ a='//tags.tiqcdn.com/utag/services-brian/main/prod/utag.js'; b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true; a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a); })(); } } //call first method and wait for data to come back then try to call utag.js jQuery.getScript("http://deploytealium.com/training/library.js") .done(function(script, textStatus) { // script loaded, call the callback tryToCallUtag("someMethodName"); }) .fail(function(jqxhr, settings, exception) { // have some sort of fall back plan console.log( "Something went wrong"+exception ); }); //call second method and wait for data to come back then try to call utag.js jQuery.getScript("http://deploytealium.com/training/library.js") .done(function(script, textStatus) { // script loaded, call the callback tryToCallUtag("someMethodName2"); }) .fail(function(jqxhr, settings, exception) { // have some sort of fall back plan console.log( "Something went wrong"+exception ); }); //call third method and wait for data to come back then try to call utag.js jQuery.getScript("http://deploytealium.com/training/library.js") .done(function(script, textStatus) { // script loaded, call the callback tryToCallUtag("someMethodName3"); }) .fail(function(jqxhr, settings, exception) { // have some sort of fall back plan console.log( "Something went wrong"+exception ); });
Copyright All Rights Reserved © 2008-2023