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 Google tag has
been added, use the gtag.js event
command with the following syntax:
gtag('event', <action>, {
'event_category': <category>,
'event_label': <label>,
'value': <value>
});
Name | Type | Default Value | Description |
---|---|---|---|
<action> |
string |
The value that will appear as the event action in Google Analytics Event reports. | |
<category> |
string |
"general" |
The category of the event. |
<label> |
string |
The label of the event. | |
<value> |
number |
A non-negative integer that will appear as the event value. |
The following sends an event with an action of 'aaa'
, a category of 'bbb'
,
and a label of 'ccc'
:
gtag('event', 'aaa', {
'event_category' : 'bbb',
'event_label' : 'ccc'
});
If <category>
or <label>
are omitted, they will be set to the default values
of "(not set)"
.
See the anatomy of Google Analytics Event parameters for more information on how the structure of events is interpreted by Google Analytics.
Default Google Analytics Events
You should use the default Google Analytics Events, which have pre-set categories and labels. Using these events facilitates consistent reporting and interoperability with future functionality.
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
});