- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
07-17-2020
01:21 AM
- last edited on
12-21-2021
10:29 AM
by
TealiumJustin
I have created a Javascript code extension for capturing the some clicks on sharepoint portal using CSS selectors. The code get is working properly when executed on console but not working in extension. Below is the small code that is used in extension:
jQuery('#myHR-css p a').click(function(){ s.linkTrackVars = 'eVar16'; s.linkTrackEvents='event14'; var active_sidebar = jQuery('.pages-menu__item.analyticsTrigger.active .pages-menu__link.analyticsTrigger.active span').text(); var c = utag_data.subSection+":"+utag_data._site+":"+ active_sidebar ; var clicktext = ($(this).text()); s.eVar16 = c+":"+clicktext; s.events = 'event14'; s.tl(this,'o',null,'navigate'); //console.log(s.eVar16) });
Solved! Go to Solution.
09-06-2020 08:44 AM
Hi @Rohan ,
The code may not be working because, the CSS selector which you are using may not be available in the inital page load. so try to modify the code like
jQuery(document).on('click', 'css selector', function () {
.....
});
Also it is not recommended to send the call explicitly to adobe by using s.tl().
You should pass these values in some UDO variables by utag.link() call and then use it in the tag by data-mapping.
You could use this link to learn more about data-mappings
https://community.tealiumiq.com/t5/iQ-Tag-Management/Data-Mappings/ta-p/10645
Thanks,
09-17-2020 09:23 PM
@Rohan Hey Rohan
Try to use the code in Preloader Extension with IF condition on URL to restrict this code to a particular page. So it should not execute across the site.
Please place Preloader Extension on top of all the extensions since Tealium follows order of operations where Preloader loads first so it will detect all your site elements.
09-21-2020 02:44 PM
Hi,
don't know if that's the case but if these CTAs cause a change of context and load other pages, maybe with click event you have troubles with some browsers.
I advice to use .on method as others said but with the "mousedown" trigger: as it gets fired before you have more chances tracking get sent before the page change.
Regards
Copyright All Rights Reserved © 2008-2023