Highlighted

I am trying to fire utag.link() upon click of a class through javascript that works well on console but not through tealium. jQuery is not present on the page . Here is the demo code

document.getElementsByClassName('cname')[0].onclick=function(){

utag.link({x:'abc'})}

}

 

it works well on console but doesn't work post deploying through tealium so tried in alternative fashion

 

(function(){

var cp=window.document.getElementsByClassName('coupon-button')[0]; cp.addEventListener("click",utag.link({Print_Coupon:'PN',link_name:'PN'}), false); })();

 

this too doesn't work

So can anyone help what could i be missing ?

3 REPLIES 3
Highlighted

I am trying to fire utag.link() upon click of a class through javascript that works well on console but not through tealium. jQuery is not present on the page . Here is the demo code

Tealium Employee
Hi Vicky, From the sounds of it, you are most likely running into a timing issue, where the code inside Tealium, is running before the content has been created on the page. Your best bet is to maybe change the scope of the extension to DOM Ready, so that it gives the page time to load before running the snippet. Adrian
Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Highlighted

I am trying to fire utag.link() upon click of a class through javascript that works well on console but not through tealium. jQuery is not present on the page . Here is the demo code

Appreciate your reply Adrian, forgot to mention scope is already set to DOM ready and tried using some delay as well but didn't work.
Highlighted

I am trying to fire utag.link() upon click of a class through javascript that works well on console but not through tealium. jQuery is not present on the page . Here is the demo code

Tealium Employee
Hi Vicky, Do you have a sample page where I could view this? If you want you can send an email to support-emea@tealium.com with the details in and I will take a look for you. Adrian
Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.