Using Omniture’s Link Handler Plug-in


 
In this tutorial you will learn how to use Omniture’s Link Handler Plug-in to capture additional data to describe links that are being clicked on.
 
Special thanks to Andreas Dierl
 
Code Mentioned
[javascript]
/*
* Plugin: linkHandler 0.5 – identify and report custom links
*/
s.linkHandler=new Function(“p”,”t”,””
+”var s=this,h=s.p_gh(),i,l;t=t?t:’o’;if(!h||(s.linkType&&(h||s.linkN”
+”ame)))return ”;i=h.indexOf(‘?’);h=s.linkLeaveQueryString||i<0?h:h." +"substring(0,i);l=s.pt(p,'|','p_gn',h.toLowerCase());if(l){s.linkNam" +"e=l=='[['?'':l;s.linkType=t;return h;}return '';"); s.p_gn=new Function("t","h","" +"var i=t?t.indexOf('~'):-1,n,x;if(t&&h){n=i<0?'':t.substring(0,i);x=" +"t.substring(i+1);if(h.indexOf(x.toLowerCase())>-1)return n?n:'[[‘;}”
+”return 0;”);

//code to capture friendly link name
var url=s.linkHandler(".zip","d");
if(url){
var currentobj=s.eo?s.eo:s.lnk;
if (currentobj && currentobj.innerHTML) {
s.eVar2 = currentobj.innerHTML;
s.linkTrackVars="eVar2";
}
}
[/javascript]
 
[javascript]
/*
* Utility Function: p_gh
*/
s.p_gh=new Function(""
+"var s=this;if(!s.eo&&!s.lnk)return '';var o=s.eo?s.eo:s.lnk,y=s.ot("
+"o),n=s.oid(o),x=o.s_oidt;if(s.eo&&o==s.eo){while(o&&!n&&y!='BODY'){"
+"o=o.parentElement?o.parentElement:o.parentNode;if(!o)return '';y=s."
+"ot(o);n=s.oid(o);x=o.s_oidt}}return o.href?o.href:'';");
[/javascript]