- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
05-22-2018 03:10 PM - edited 05-22-2018 03:38 PM
If I want to use this function(utag.gdpr.showExplicitConsent();) on our site, how can I let it run after the `utag.js` finish loading?
Thanks
Solved! Go to Solution.
05-22-2018 06:09 PM
While the utag.gdpr object is instantiated fairly early in utag.js being loaded, utag.gdpr.showExplicityConsent() isn't available until DOM Ready. So if you need to use the function then scope your extension to DOM Ready and it will be injected after the function is declared.
Please let me know if this helps solve your problem.
05-22-2018 07:19 PM
Thank you! It solves the problem. @dan_george
05-23-2018 06:57 AM
Oh. @dan_george
I'm sorry. But after like 50 times tests, we are still able to see this error once or twice.
We are using the `$(document).ready()`.
05-23-2018 07:55 AM
This still seems like a timing issue. The utag.gdpr.showExplicitConsent()
is instantiated at DOM Ready and you're also attempting to trigger your code at DOM Ready.
It's not directly stated but I presume you added the code to a JS extension, if so scope your extension to DOM Ready (not of All Tags) instead of using the $(document).ready()
wrapper. This will make your extension run after utag.gdpr.showExplicitConsent()
is declared since we handle ordering the function declarations.
05-23-2018 10:10 AM - edited 05-23-2018 10:38 AM
It works.
We didn't use the Extension section. After seeing your suggestion, we moved the code to the Extension and it works.
Thank you so much! Wish you a great day! @dan_george
And btw, if we cannot put it in the JS Extension, is there a way to solve this problem?
Copyright All Rights Reserved © 2008-2023