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]
 
 

Join the Conversation

6 Comments

  1. Using the innerHTML to name the download- genius! Why didn’t I ever think of that?! Thanks for this.

  2. Thanks for this, it works great.
    Only problem I’m having is that when I correlate pageName with a prop that I’m populating the value into, I’m seeing “unspecified” – both pagename and prop are capturing values as seen in their individual reports. The image request is being fired off and I do see both the prop value and the pageName in that image Request. What have I don’t wrong?

    1. Martin- if you’re sending in the data with a s.tl call (like most link tracking), then pageName is not going to get a page View accredited to it. It will show up in a packet sniffer but won’t be processed as a page view. That page might show up in your pages report because it is getting non-link-related pageviews, but typical link clicks won’t show up as page Views in the pages report.

      If you want to correlate a prop with the page a link is clicked on, you can either set both the pageName in an extra prop then correlate with THAT, or you can treat the link click as a true pageview by setting s.t() instead of s.tl(). Unfortunately the linkhandler plugin isn’t able to do the latter.

  3. Hi, can you give an example of how this would work for custom link tracking? Is the syntax the same? If so, what would go in place of the ‘.zip’ file extension in the function? Thx.

    1. Shawn, the link handler plugin takes two parameters. The first is a pipe delimited string a name=filter paris. The second is the type of link, this parameter is optional and if omitted defaults to custom link. The valid values for link type are “o” for a custom link, “d” for a download link, and “e” for an exit link. For your example, the call could look something like the following, assuming you wanted to track all clicks on links that looked like ‘linkA’ and ‘linkB’ (where linkA and linkB are filters you are looking to match) as custom links: var url=s.linkHandler(“Link A Click=linkA|Link B Click=linkB”,”o”);

Leave a comment

Your email address will not be published. Required fields are marked *