Capture Download Link Text
Blog RSSWhat's Happening
Featured
Recently I had a client request to capture the link text associated with PDF downloads from their site. I scratched my head for awhile and finally decided the best option was to ask the Twitter community for help.
My good buddy Andreas came to the rescue. The Goal Capture 'The Dude - A Complete Biography', from the link below, into a custom conversion variable.
href=site.com/the_dude.pdf" link text="The Dude - A Complete Biography"
The Code
var url=s.linkHandler(".pdf","d");
if(url){
var currentobj=s.eo?s.eo:s.lnk;
if (currentobj && currentobj.innerHTML) {
s.eVar1 = currentobj.innerHTML;
s.linkTrackVars="eVar1";
}
}
The Result
s.eVar1="The Dude - A Complete Biography";
Thanks Andreas, the code is clean, concise, and accomplished exactly what I needed! NOTE: The above requires the addition of the linkHandler plugin to your s_code.js file. Jason Thompson is a Senior Analytics Consultant at Numeric Analytics. You can follow him on Twitter at twitter.com/usujason.
Must be logged in to comment. Login or register now to comment!