- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
10-13-2016 05:25 AM
We have a couple of old legacy JavaScript libraries that are full of global functions. We'd like to migrate these into Tealium, but the functions become unaccessable on the pages due to the way Tealium wraps everything in their function templates.
Is there any other way to migrate these, other than to go through the JavaScript files and update every function to be on the window rather than scoped to the Tealium wrapper?
Solved! Go to Solution.
10-13-2016 06:40 AM
10-13-2016 06:43 AM
10-13-2016 08:11 AM
@craig_rouse - The work-around we are going with right now is to put all of the code in the tag template. Not a fan of this, becuase now we have to maintain code in multiple places. We'd rather see Tealium provide a tag template that will load an extension without any Tealium wrappers. Or maybe you can suggest a way to setup the template to pull from the extension without wrapping in any Telium code?
10-13-2016 08:22 AM
10-13-2016 08:51 AM
I think our replies may have crossed paths. Good to know we were on the same path here as you outlined. As I mentioned, the biggest reason we don't like this is that code now has to be maintained by our team in extensions (generally), and now we have this one-off tag where all the code is maintained in the tag template. Just not very clean when we have a team of 10 maintaining various implementations. A work-around that seems to do the job, but not one we feel is scalable across the enterprise.
Here's our flow, I'd love to hear your feedback on our approach:
10-13-2016 09:05 AM
12-02-2016 07:14 AM
If you want to load from an external file through Tealium, you can do this. And it will be wrapped in the loading code that is needed.
All you need to do, is use for example a Custom Container tag, and go Advanced Settings > Custom Script Source. And place the URL of the file you want to load.
Adrian
08-29-2018 12:02 PM - edited 08-29-2018 12:06 PM
Following on from @jrmy great idea; another solution is to load the global tag as a 'regular' tag and when it's complete call 'utag.link' in the callback with a custom event parameter (e.g. 'GlobalFinished'). Setup any dependent tags to only fire on utag.link ( u.ev = {'link' : 1}; ) and configure the load rules to look for the 'GlobalFinished' event parameter.
This has an advantage of not blocking any other tags loading while the global functions are being added to the page but still guarantees that the dependent tags wait for the global tag to complete.
This was my approach for Google's global gtag JS where a number of other Google tags rely on this being present before firing (e.g Google Analytics, Google AdWords etc...)
Copyright All Rights Reserved © 2008-2023