Rudi Shumpert : Code By Numbers
23Jul/092

jQuery FTW! Auto-tag static links for Omniture.

I am knee deep in implementing Omniture into our existing corporate site, and sometimes.... the path is clear as mud. The task of the day was to tag a set of links so that they would show up as Products in SiteCatalyst. The sub-task, ok maybe my personal bias, was to do so in a way that I would not have to babysit the page and keep updating the tags as new links were added.

Problem: How do you take a static list of hyperlinks on a set of pages and go about setting up some method to tag each of these links with a Javascript call to Omniture.  Also trying to put in some type of future proofing so that ongoing updates to this file(s).

Environment: ColdFusion8 Server / jQuery

My Approach:

$(document).ready(function(){
   $('#divToBeTagged a').each(function(i) {
       var hrefval = $(this).attr('href');
       $(this).bind('click',function (event){
          omnitureJSCall('Product Category',hrefval)
       });
    });
});

I went with this for a few reasons, the main one being the ease of future updates to this page. I work on a small team of dev's and anyone else could be making updates to this page and with this method, we will always have the correct tags on our product downloads on this page. Is it perfect? Nah... but it does work well for me.

-RRS

Rudi Shumpert is the Senior Director -Technology Solutions Group & Principal Consultant with Keystone Solutions, based in the Atlanta area. If you would like to work with Rudi email him at rudi@keystonesolutions.com. You can follow him on Twiter, connect on LinkedIn, or listen to him on the Beyond Web Analytics Podcast.

Comments (2) Trackbacks (0)
  1. This is exactly the kind of thing I had in mind. I’m glad to see that someone has tried it already, and I’m guessing with success? Thanks for sharing.


Leave a comment


No trackbacks yet.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes