Event tracking in Google Analytics is a really useful way of monitoring user interactions with your website. It's often used for tracking embedded AJAX page elements and file downloads. We've been using it at work to to monitor how people are interacting with the numerous forms on a social network style site.
To track an event we use the _gaq.push method like this:-
_gaq.push(['_trackEvent', 'Category', 'Action', 'Label']);
Category, action and label all need replacing with what ever is appropriate for what you are tracking.
The first time we implemented this we stuck the _gaq.push method in the form's onsubmit call, but this wasn't working. Google Analytics wasn't properly logging the events. The problem was that the event wasn't being logged in time before the page was redirected. The solution was to call the method on the onclick event for the form's submit button:-
<input type="submit" onclick="_gaq.push(['_trackEvent', 'Category', 'Action', 'Label'])" />
With this in place the event got tracked when the form was submitted and our analytics account quickly filled with useful data.
Hopefully this tip will help others of you out that scratching your heads on where your data is.
