- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
04-28-2016 05:20 AM
On our website, we get some data from another service asynchronously, e.g. the other service is called and some data returned and written into a JavaScript object.
We want to copy this data into the utag_data object and map it to several Web Analytics tools.
But there is a race condition of course: We cannot bet on the other service to have the data ready when the Tealium script starts to run. So what I would like to do is to have the Tealium script wait until the other data is there via Polling.
Is there a way to do this via a Pre-Loader Extension?
By the way, I know there is the "noview" config parameter, but setting this parameter is too risky for me as it changes the entire loading logic.
04-28-2016 06:30 AM
04-28-2016 08:49 AM
Building off of @steve_lake's comments, this will disable the initial pageview trigger that "utag.js" sends by default when it is loaded.
When doing so, you then will have to have to fully gather/generate all your data points into your data object (e.g. utag_data). Once you know you have all the data you need in your object, then you'll manually trigger the your page view call, passing in your data object.
For example:
// Waiting for 3rd-party data to come back here var thirdPartyData = "foo"; // Pushed 3rd-party data into my utag_data object window.utag_data = window.utag_data || {}; window.utag_data.product_id = thirdPartyData; // Then manually trigger your page view utag.view(utag_data);
There's really no other robust solution as Tealium does not know when your asynchronous service will finish and return its data. You will have to control that logic and manually send the page view call when you have received your data.
Just to reiterate as Steve already mentioned, using the "noview" override will 100% disable the page view call from triggering before your third-party service finishes.
Hope this helps!
04-29-2016 12:29 AM
Hi @meng_lim and Steve Data Lake,
thanks, not what I wanted but totally understandable.
I cannot change the HTML on the page itself. Is it viable to fire the utag.view through a DOM Ready Extension or a Pre-Loader Extension?
What if I have other DOM Ready Extensions that are supposed to fire Event Calls right after the Pageview? My fear is that they will fire before the pageview call.
Best
Lukas
05-04-2016 08:23 PM
Are your DOM-Ready scoped extensions relying on this other service? If so, then you will have to change the scope of your extension(s) to execute when the other service has finished. Otherwise, you will continue to run into issue of a race condition.
All track calls (i.e. view/link) will have to be consolidated to fire when and only when your other service(s) has finished and returned its data back to you.
Copyright All Rights Reserved © 2008-2023