- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
In the current scoping options for extensions (specifically javascript extensions) we have the option to choose preloader which executes prior to utag being defined. Any call to utag functions (eg. utag.DB) will obviously fail. If choosing the scope of all tags, the extension is ran at every call to utag.view/link but the utag.DB works.
The usecase I am working on requires me to use a js extension that runs only once but has utag allready defined. To clarify I would need a scope of utag ready which executes after preloader but before the all tags extensions(if any).
This seems a lot like a feature request and my usecase might be less important for other customers but having a scope which only runs once after the core of tealium is loaded might superced the usage of preloader in a lot of cases and would enable me to (re)use functions in in the tealium code.
Currently I have a working POC which polls the availability of utag ,utag.handler && utag.handler.iflag which seems to be a crazy hack but works nicely
code:
waitUntil( function checkforutagavailability(){ return utag && utag.handler && utag.handler.iflag === 1 } ,runother function ,20 ,1000 );
where watUnitll checks every 20ms if the utag && utag.handler etc is available and runs at maximum for 1second or calls the runotherfunction if the validation works.
Is this a plausible solution, do you have any other idea and is there any chance whether this type of 'scope' could be a feature in Tealium?
06-03-2016 09:48 AM - edited 06-03-2016 11:35 AM
Great question and I am sure there are many ways to approace the solution. The most common way would be the following:
if(typeof utag.runonce['my_code_init'] === 'undefined'){ utag.runonce['my_code_init'] = true; // run the rest of your code here. // your code will only run once because of the if block }
@richard_udovich and @jan_van_damme
If you scope to "All Tags" or "DOM Ready" then utag will be available. The only scope that will not have utag is "Pre Loader". If you need this extension to run first, then you can move it up higher in the list of extensions (you can drag and drop the extensions to change the execution order).
Also you can Scope to "All Tags" - "Before Load Rules" which run before the default "After Load Rules"
Hope this helps.
If not, reach out by opening a support case and one of our engineers can work with you on your specific website:
https://community.tealiumiq.com/t5/custom/page/page-id/support-contact-form
Copyright All Rights Reserved © 2008-2023