Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Bronze Contributor
Bronze Contributor

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

 

5 REPLIES 5

Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Tealium Employee

@anthea777

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.

Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Bronze Contributor
Bronze Contributor

Thank you! It solves the problem. @dan_george

Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Bronze Contributor
Bronze Contributor

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()`.

Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Tealium Employee

@anthea777

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.

 

Randomly seeing this error: `utag.gdpr.showExplicitConsent();` is not a function.

Bronze Contributor
Bronze Contributor

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?

Public