Event Tracking

This guide explains how to implement event tracking with analytics.js.


Events are user interactions with content that can be tracked independently from a web page or a screen load. Downloads, mobile ad clicks, gadgets, Flash elements, AJAX embedded elements, and video plays are all examples of actions you might want to track as Events.

If you're unfamiliar with events in Google Analytics you should first read the article About Events in the Analytics Help Center.


Event hits can be sent using the send command and specifying a hitType of event. The send command has the following signature for the event hit type:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

Event fields

The following table summarizes the event fields:

Field Name Value Type Required Description
eventCategory text yes Typically the object that was interacted with (e.g. 'Video')
eventAction text yes The type of interaction (e.g. 'play')
eventLabel text no Useful for categorizing events (e.g. 'Fall Campaign')
eventValue integer no A numeric value associated with the event (e.g. 42)

For a more in-depth description of each of these fields, see Anatomy of an Event in the Analytics Help Center.


The following command sends an event to Google Analytics indicating that the fall campaign promotional video was played:

ga('send', 'event', 'Videos', 'play', 'Fall Campaign');

Note that as with all send commands, the fields passed in the convenience parameters may also be specified in the fieldsObject. The above command could be rewritten as:

ga('send', {
  hitType: 'event',
  eventCategory: 'Videos',
  eventAction: 'play',
  eventLabel: 'Fall Campaign'

When a user clicks a link that points to another page on your site, that page typically sends a pageview hit as the user arrives. Because there's a series of pageviews, Google Analytics can figure out on the back end where the user navigated to (and from). But if a user clicks a link or submits a form to an external domain, that action is not captured unless you specifically tell Google Analytics what happened.

Outbound link and form tracking can be accomplished by sending events and specifying the destination URL in one of the event fields. The following event handler function can be used to send outbound link click events to Google Analytics:

function handleOutboundLinkClicks(event) {
  ga('send', 'event', {
    eventCategory: 'Outbound Link',
    eventAction: 'click',
    eventLabel: event.target.href

Tracking outbound links and forms can be tricky because most browsers will stop executing JavaScript on the current page once a new page starts to load. One solution to this problem is to set the transport field to beacon:

function handleOutboundLinkClicks(event) {
  ga('send', 'event', {
    eventCategory: 'Outbound Link',
    eventAction: 'click',
    eventLabel: event.target.href,
    transport: 'beacon'

For browsers the don't support the beacon transport method, you have to postpone navigating to the next page until the event has finished sending. The Knowing when a hit has been sent section of the guide on Sending data to Google Analytics explains how to do this in detail.

Non-interaction events

In some cases you might want to send an event as a non-interaction event. To do this, specify the nonInteraction field as true in the fieldsObject of the send command:

ga('send', 'event', 'Videos', 'play', 'Fall Campaign', {
  nonInteraction: true

For more information on non-interaction hits and when to use them, read about non-interaction events in the Analytics Help Center