- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-15-2013 03:39 AM - last edited on 10-08-2015 01:31 PM by kathleen_jo
So at the moment I have following JS extension:
jQuery('.chat').click(function() {
var chat_source = jQuery('.chat').attr('data-source') ? jQuery('.chat').attr('data-source') : (jQuery('.chat').attr('name') ? jQuery('.chat').attr('name') : "Undefined source. Talk to Web team.");
// SiteCatalyst
if(s){
s.linkTrackVars = "eVar1,eVar2,events";
s.linkTrackEvents = s.events = "event1";
s.eVar1 = "D=g";
s.eVar2 = chat_source;
s.tl(this,"o","Chat Started");
}
}
How do I convert this code into Tealium jQuery onHandler extension?
Solved! Go to Solution.
08-15-2013 04:02 AM - last edited on 10-08-2015 01:38 PM by kathleen_jo
Hi Tomas,
So what you will need to do if you want to use the jQuery Event handler is to:
1) Select the appropriate extension so either 1.6 and below / 1.7 and above
2) Set the selector to ".chat"
3) Change Trigger On to on click
4) Set Tracking Event to custom
5) Add the following code to the JS text are:
//---Start
var chat_source = jQuery('.chat').attr('data-source') ? jQuery('.chat').attr('data-source') : (jQuery('.chat').attr('name') ? jQuery('.chat').attr('name') : "Undefined source. Talk to Web team.");
utag.link({
"chart_source":chart_source,
"linkTrackVars": "eVar1,eVar2,events",
"linkTrackEvents" : "event1",
"URL" : utag.data['dom.url'],
"link_text":"Chat Started"});
//---End
In the mappings for the Site Catalyst Tag make sure that you have a mapping for:
chart_source to eVar2
URL to eVar1
and a event mapping for event1 to be fired when link_text equals "Chart Started"
Hope this helps
Adrian
08-15-2013 06:33 AM
08-15-2013 07:21 AM - last edited on 10-08-2015 01:39 PM by kathleen_jo
Hi Thomas,
You are indeed correct there is functionality to allow you to auto link tracking.
It is more out of habit that I set these as it means no other values will be sent across if an extension was populating other variables.
If you are happy that nothing else will be set or if anything else is added you are happy for that to be sent across as well, then feel free to remove these key value pairs from the JSON object.
Adrian
08-15-2013 07:32 AM
08-15-2013 07:36 AM - last edited on 10-08-2015 01:31 PM by kathleen_jo
Adding to Adrians Comment, if you do not want custom js code you can select "Link" in the Tracking Event drop down. Then you can add a new variable, chat_source. Select Chat source from the first drop down then select JS Code in the "To:" drop down and paste the in-line if statement into the box:
jQuery('.chat').attr('data-source') ? jQuery('.chat').attr('data-source') : (jQuery('.chat').attr('name') ? jQuery('.chat').attr('name') : "Undefined source. Talk to Web team.");
Then select "link_text" as the next variable, leave the "To:" box as Text and type in "Chat Started"
Then you can add URL as a new variable and select variable from the "To:" drop down and select url as the option. However, if eVar1 is always mapped to the URL this step isn't needed.
Then just as Adrian said make sure you have the mappings set up for chat_source and the event mapping defined.
If you are on the H25 or H26 linkTrackVars and linkTrackEvents will get set automatically for you.
So in the end it will look like this:
08-15-2013 08:47 AM
08-15-2013 09:16 AM
08-15-2013 09:29 AM
08-15-2013 09:57 AM
08-15-2013 10:14 AM
08-16-2013 05:48 AM
08-16-2013 07:58 AM
08-16-2013 09:36 AM
10-08-2015 03:37 PM
Copyright All Rights Reserved © 2008-2023