Highlighted

jQuery on handler custom tracking

Silver Contributor
Silver Contributor
Hello,

I am trying to understand how to access the selector object in custom tracking window.

Basically I have
jQuery selector = a[onclick]
Trigger = click
Tracking = custom

I was using the following JS code if I would have a specific CSS selector.

$(this).attr(onclick)

But I want to use the custom tracking as I want to evaluate and send custom tracking events to vendor. But $(this) doesn’t seems to be working? How do I access selector object.

Cheers

1 REPLY 1
Highlighted

jQuery on handler custom tracking

Gold Contributor
Gold Contributor
Hello @zhaque,

I would suggest you to proceed with JavaScript extension instead going for jQuery extension since you are expecting to go with Custom tracking events. Please find below sample code for your reference to proceed further. If you use JavaScript extension use "document.getElementsByClassName" or "document.getElementById".

var abc = setInterval(function() {
if (document.readyState !== 'complete') return;
clearInterval(abc);
var xyz = document.getElementById('SELECTOR ID').onclick = function()
alert(xyz);
});

Hope it helps! Please let us know if you need any clarifications. Happy Learning!!!