- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
06-13-2013 07:58 PM
06-13-2013 08:26 PM - last edited on 08-06-2016 12:47 PM by kathleen_jo
Hi Johann, The Link Tracking Extension is our legacy link tracking extension (before introducing the jQuery Extensions.) The original intent was to provide instant link tracking for all links on the page back when Google Analytics didn't have this built-in. For custom link filters, we now recommend using the jQuery Extensions and the powerful selectors that jQuery provides for determining download, exit links, etc.
06-13-2013 11:01 PM
06-14-2013 10:22 AM - last edited on 10-06-2015 09:59 PM by akshata_yerdoor
Hi Johann, I have a jQuery extension that I created for another client. Here are the details.
- Set your jQuery selector
- Choose "mousedown" as the trigger event
- Choose "custom" as the track event
- In the textarea, here is the code I wrote:
y=this.href; setTimeout(function(){ var a=document.createElement('a'); a.href=y; z=a.hostname; if(z!=utag.data["dom.domain"] && y.indexOf("javascript:")==-1){ utag.link({ ga_category: "offsite link", ga_action: "click", ga_label: y }); } },300);
What this code does:
First, grab the link contents
Second, a setTimeout of 300 milliseconds is used to ensure the call has time to run before the page is redirected. This is mainly for Google Analytics since they require a 200 response from the server in order for the event to be tracked.
Third, capture the domain of the link click into "z"
Fourth, compare "z" to the domain of the current page (utag.data["dom.domain"]). It also checks to ensure it's not an internal link (javascript : ).
Last, it calls our utag.link method and passes the link click details. The GA template will then automatically be called to fire off the event to GA.
To do the same for internal links, you will just change the conditional statement to check if the link domain equals that of the current domain. It's really just switching conditionals and comparing the appropriate data.
Let me know if this doesn't meet your needs.
06-14-2013 11:58 AM - last edited on 10-06-2015 10:03 PM by akshata_yerdoor
Here is a jQuery selector for Exit Links (assuming my domain is 'tealium.com').
Replace the tealium.com with your domain.
jQuery('a[href^="//"],a[href^="http"]').not('a[href*="tealium.com"]');
Unfortunately because I'm using the ".not" function, this has to be in a Javascript Extension (outside of the built-in jQuery Extension)
Any jQuery gurus out there who can rewrite this so it works in our jQuery onHandler extension in the "jQuery Selector" field? I'll do some research myself in a bit..
06-14-2013 02:27 PM - last edited on 10-06-2015 10:04 PM by akshata_yerdoor
06-19-2013 06:53 PM
Copyright All Rights Reserved © 2008-2023