Here are the few lines that enable Woopra analytics on my site via the jQuery Woopra plugin. I've left in the jQuery Google Analytics plugin code so you can see the similarities and differences in syntax between the two.
$('#refine_by').livequery(function(){$('#refine_by').track({
category : 'refine_by',
action : 'click'})})
$('#refine_by').livequery(function(){$('#refine_by').trackEvent({
title : 'refine_by'})
})
$('#sites ul li').livequery(function(){$('#sites ul li').not('#reset_sites').track({
category : 'site',
action : 'click',
label : function(element) {return element.text()}}
)})
$('#sites ul li').livequery(function(){$('#sites ul li').not('#reset_sites').trackEvent({
title : 'site',
label : function(element) {return element.text()}
})})
$('#categories ul li').livequery(function(){$('#categories ul li').track({
category : 'category',
action : 'click',
label : function(element) {return element.text()}
})})
$('#categories ul li').livequery(function(){$('#categories ul li').trackEvent({
title : 'category',
label : function(element) {return element.text()}
})})
Let's go over a couple of these lines.
$('#refine_by').livequery(function(){$('#refine_by').trackEvent({
title : 'refine_by'})
})
- $('#refine_by') - the element being tracked
- .livequery(function()($('#refine_by') - because the element is not created when the DOM is ready, I am using the livequery plugin to actively apply the tracking rule each time the #refine_by element gets created via AJAX. If you're using jQuery 1.3 you can use the built-in live method to achieve the same purpose.
- .trackEvent({title : 'refine_by'}) - the only parameter I'm passing through in this example is the title of the event
Now let's look at one of the more complex examples, where I'll be tracking the sites in the list in #sites ul li:

$('#sites ul li').livequery(function(){$('#sites ul li').not('#reset_sites').trackEvent({
title : 'site',
label : function(element) {return element.text()}})
})The main difference here is that I'm passing a function to the label property. This particular function evaluates the text of the li element that is clicked on and stores it in Woopra. This lets me track which site in the list the visitor has clicked on.
To track an a element I might use something like this:
$('div#site_details a').trackEvent({
title : 'site_details',
label : function(element) {return element.attr('href')}
})I didn't use livequery in this statement because of where it was placed in my code. I placed it where the a elements are created, so there's no need to apply the code to any elements that haven't yet been created. The label property is now storing the URL of the a element being tracked.
Note that all a elements are being tracked, and whichever particular one is clicked, that one's URL will be returned. So for example, in the example below, there are three a elements (in red).