- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
10-19-2015 06:39 AM
I want to write a javascript in extension that will track which Social Network button (facebook, twitter, instagram) have I clicked. Currently, all the Social buttons have the same class name (hence I could not use jQuery Selector from WebCompanion to capture which Social button is clicked).
Also, In the coding, the Social buton have be coded in <a href> and <img alt>.
Please help to understand how can I write an javascript to track the social network button. Thank you.
Solved! Go to Solution.
10-19-2015 07:55 AM - edited 10-19-2015 07:57 AM
Hi prathamesa_thak,
If your class name is the same and you are unable to add a unique ID, perhaps you can track the button by its inner text assuming that this is unique for each of the social media buttons.
For example, say your HTML anchor code for the Facebook button looks like this:
<a href="www.facebook.com/examplePage" class="socialmedia">Facebook Page</a>
Then you jQuery onHandler can look something like this:
jQuery(document.body).on('mousedown', 'a.socialmedia:contains("Facebook")', function(e) { utag.link({ event_type: 'social_media_click' }); });
Is this what you are trying to accomplish?
10-21-2015 02:34 AM
Hello Menf_Lim, Thank you for your reply.
Let me check and get back to you
Appreciate your reply.
Copyright All Rights Reserved © 2008-2023