Track Google Analytics Events

This page explains how to use gtag.js to send Google Analytics Events.

Send events

To send Google Analytics Events on a web page where the tracking snippet has been added, use the gtag.js event command with the following syntax:

gtag('event', <action>, {
  'event_category': <category>,
  'event_label': <label>,
  'value': <value>
});
  • <action> is the string that will appear as the event action in Google Analytics Event reports.
  • <category> is the string that will appear as the event category.
  • <label> is the string that will appear as the event label.
  • <value> is a non-negative integer that will appear as the event value.

The following example fires a Google Analytics Event with an action of 'xyz', a default category of 'general, and a default label of '(not set)':

gtag('event', 'xyz');

Override the default parameter values by assigning your own values in your code. The following fires a Google Analytics Event with an action of 'aaa", a category of 'bbb', and a label of 'ccc':

gtag('event', 'aaa', {
  'event_category' : 'bbb',
  'event_label' : 'ccc'
});

Learn more about the anatomy of Google Analytics Event parameters (i.e. category, action, label, and value).

Default Google Analytics Events

In most cases, you should use the default Google Analytics Events, which are pre-set with default categories and labels. Using these events facilitates consistent reporting and interoperability with future functionality.

This example fires a Google Analytics Event with an action of 'login', a category of 'engagement', and a label of 'Google':

gtag('event', 'login', { method : 'Google' });

The following table lists the default Google Analytics Events, their default categories, and default label types (if available). For event names not listed in this table (e.g. arbitrary event names that you create), the default category is 'engagement' and the default label is 'not set'.

Event name Default category Default label type
add_payment_info ecommerce  
add_to_cart ecommerce  
add_to_wishlist ecommerce  
begin_checkout ecommerce  
checkout_progress ecommerce  
generate_lead engagement  
login engagement method
purchase ecommerce  
refund ecommerce  
remove_from_cart ecommerce  
search engagement search_term
select_content engagement content_type
set_checkout_option ecommerce  
share engagement method
sign_up engagement method
view_item engagement  
view_item_list engagement  
view_promotion engagement  
view_search_results engagement search_term

Send non-interaction events

To send a non-interaction event, set the non_interaction parameter to true:

gtag('event', 'video_auto_play_start', {
  'event_label': 'My promotional video',
  'event_category': 'video_auto_play',
  'non_interaction': true
});