Created
December 6, 2017 23:34
-
-
Save ryanpraski/d9715ca096706224b9d42a8c7852be34 to your computer and use it in GitHub Desktop.
Adobe Analytics Automatic Link and Download Tracking Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isDownloadLink = function(lnk) { | |
var isDownload = false; | |
if (typeof lnk.href !== 'undefined') { | |
var fileTypes = window.s.linkDownloadFileTypes.split(','); | |
var href = lnk.href.toLowerCase(); | |
for (var k = 0; k < fileTypes.length; k++) { | |
if (href.indexOf(fileTypes[k].trim()) > -1) { | |
isDownload = true; | |
break; | |
} | |
} | |
} | |
return isDownload; | |
} | |
var isExitLink = function(lnk) { | |
var isExit = true; | |
if (typeof lnk.href !== 'undefined') { | |
var intLinks = window.s.linkInternalFilters.split(','); | |
var href = lnk.href.toLowerCase(); | |
for (var l = 0; l < intLinks.length; l++) { | |
if (href.indexOf(intLinks[l].trim()) > -1) { | |
isExit = false; | |
break; | |
} | |
} | |
} else { | |
isExit = false; | |
} | |
return isExit; | |
} | |
$(document).on('click','a',function() { | |
if (typeof this.href != 'undefined') { | |
if (isDownloadLink(this)) { | |
//track download links | |
s.linkTrackVars = 'prop1,prop2,eVar1,eVar2'; | |
s.linkTrackEvents = ''; | |
s.events = s.linkTrackEvents; | |
s.tl(this,'d',this.href); | |
} else if (isExitLink(this)) { | |
//track exit links | |
s.linkTrackVars = 'prop1,prop2,eVar1,eVar2'; | |
s.linkTrackEvents = ''; | |
s.events = s.linkTrackEvents; | |
s.tl(this,'e',this.href); | |
} eise { | |
//track custom links | |
} | |
} else { | |
//track custom links | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment