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

Leave a comment

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

Are you human? Or are you Dancer? *

4 thoughts on “jQuery FTW! Auto-tag static links for Omniture.”