Archive for Google Analytics

Google Event Tracking

// November 6th, 2009 // No Comments » // Development, Google Analytics, Javascript, JQuery

I was asked recently if there was any way to track click events on an accordion we have implemented on a site. When first asked I didn’t think this was possible without an awful lot of javascript. However, a colleague mentioned Google event tracking is already available in Google if you have the standard setup. You can attach various events on various elements. The example on the google site is attaching the event to a play button.

Event tracking is so simple to impliment. You don’t even have to set anything up within anaylitics, you simply add the tracking event, and when events happen, this will be recorded. The format for the event is:

_trackEvent(category, action, optional_label, optional_value)

To impliment it using JQuery, I simply added a click event to the element like this:

$('#accordion h3 a').click(function()
	//get the section title
	var section_title = $(this).text();
	//call pageTracker and track the event
	pageTracker._trackEvent("recipes", "click", section_title);