jQuery google analytics event tracking

Here is how to track events for Google Analytics. There used to be a lot more information here however, now, the best way to learn is to visit the following references:

Events: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Explanation of differences in old and new JS, which also servers as a great cheat sheet: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs

Using virtual page views for events, helpful for creating funnels (funnels normally can't be used on events, only page views)

Using the new recommended analytics.js, label and value are optional:
if (typeof ga != "undefined") {
  $('body.page-home #accordion-special-offers').click(function(){
    ga('send', 'event', 'Category', 'Action', 'Label', Value);
    ga('send', 'event', 'Home', 'Clicked', 'Products Special Offers Accordion');
  });
}
Using the old deprecated ga.js:
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking
// _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
// category (required)
// The name you supply for the group of objects you want to track.
// action (required)
// A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.
// 
// label (optional)
// An optional string to provide additional dimensions to the event data.
// 
// value (optional)
// An integer that you can use to provide numerical data about the user event.
// 
// non-interaction (optional)
// A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation.
// 
if (typeof _gaq != "undefined") {
  $('body.page-home #accordion-special-offers').click(function(){
    _gaq.push(['_trackEvent', 'Home', 'Clicked', 'Products Special Offers Accordion']);
  })
}

Article Type

General