Global Site Tag (gtag.js) Events

Master event tracking in Google Analytics 4 with gtag.js for seamless user interaction monitoring and deeper insights.

Ceyhun Enki Aksan
Ceyhun Enki Aksan Entrepreneur, Maker

Google Analytics, Global Site Tag, Google Tag Manager and Google Ads articles separately discuss the concept of Event (event).

tip

You can reach out for support regarding Google Analytics here.

Google Analytics Events

Although ga.js1, followed by analytics.js2 and finally gtag.js3 4 have different usage patterns, events generally begin with page load interactions (hitType/pageview) and track all user interactions within a page (hitType/event) throughout the session, enabling interaction tracking and maintaining it under the Google Analytics account. Events can be tracked independently of a web page load or mobile screen load. Various user interactions such as downloads, clicks (links, buttons, form elements, images, etc.), gadgets, Flash elements, embedded AJAX components, scroll actions, session processes, and videos can be captured during the definition phase.

It’s worth highlighting the difference between Page Tracking and Event Tracking. Page Tracking (page tracking) measures the number of times a specific page is viewed on a website and serves as a foundation for other activities5. Pages typically correspond to the entire HTML document, but can also represent dynamically loaded content (virtual pageviews). Event Tracking, on the other hand, refers to user interactions performed on content that is independent of a web page or screen (such as mobile, AR, VR, or other user interfaces). Examples of such interactions include downloads, ad clicks, gadget interactions, Flash elements, AJAX embedded elements, video plays, and similar actions. A basic event is communicated through the following function parameters:

// UA
gtag('event', '<action>', {
  'event_category': '<category>',
  'event_label': '<label>',
  'value': '<value>'
});

// GA4
gtag('event', '<myCustomEvent>', {
  "TheEventAction": "<myEventAction1>",
  "TheEventLabel" : "<myEventLabel1>"
});

Using the gtag() function in conjunction with gtag.js, the system has gained the ability to more efficiently utilize Default Google Analytics Events when sending an event via the send parameter of the ga() function in analytics.js. An example of a predefined gtag event, such as a login, is shown below6:

// UA & GA4
gtag('event', 'login', { method : 'Google' });

In addition to user engagement events, commerce events (ecommerce) are also available for use. Below you can see the default Google Analytics Events definitions related to Universal Analytics (UA)7.

Activity NameDefault CategoryDefault Event Type
searchengagementsearch_term
generate_leadengagement
loginengagementmethod
select_contentengagementcontent_type
shareengagementmethod
sign_upengagementmethod
view_itemengagement
view_item_listengagement
view_promotionengagement
view_search_resultsengagementsearch_term
add_payment_infoecommerce
add_to_cartecommerce
add_to_wishlistecomaret
begin_checkoutecommerce
checkout_progressecommerce
purchaseecommerce
refundecommerce
remove_from_cartecommerce
set_checkout_optionecommerce

GA4 (Google Analytics 4) recommends automatically collected (automatically collected events)8 events for all web sites and apps, retail sales and e-commerce, businesses, education, local opportunities and real estate, travel and games. Below you can see the activities grouped by e-commerce.

EventTriggerParameters
add_payment_infoUser submits payment detailscoupon, currency, items, payment_type, value
add_shipping_infoUser submits shipping detailscoupon, currency, items, shipping_tier, value
add_to_cartUser adds an item to their shopping cartcurrency, items, value
add_to_wishlistUser adds an item to their wishlistcurrency, items, value
begin_checkoutUser starts the checkout processcoupon, currency, items, value
generate_leadUser submits a form or requests informationvalue, currency
purchaseUser completes a purchaseaffiliation, coupon, currency, items, transaction_id, shipping, tax, value
refundRefund is issuedaffiliation, coupon, currency, items, transaction_id, shipping, tax, value
remove_from_cartUser removes items from their shopping cartcurrency, items, value
select_itemUser selects an item from a listitems, item_list_name, item_list_id
select_promotionUser selects a promotionitems, promotion_id, promotion_name, creative_name, creative_slot, location_id
view_cartUser views their shopping cartcurrency, items, value
view_itemUser views an itemcurrency, items, value
view_item_listUser views an item or promotion listitems, item_list_name, item_list_id
view_promotionUser is shown a promotionitems, promotion_id, promotion_name, creative_name, creative_slot, location_id

GA4 events are categorized by event name and are available under the appropriate report. Event names defined in e-commerce can be found under e-commerce reports, while viewing all events and marking specific events as conversions is also possible.

In UA reports, you can view these activities in detail under Google Analytics account > Property > View > Behavior; in GA4 reports, you can access them under Engagement > Events, Events > All Events.

Google Analytics Events
Google Analytics Events

Additionally, under the Secondary Dimension, you can use the Most Commonly Used and Behavior options to select Event Action, Event Label,, and Event Category, and filter using Advanced Search. The same path can also be used to track during the segmentation process.

Google Analytics Events
Google Analytics Events

You can also use the Google Analytics Debugger Chrome extension for event testing and debugging.

Footnotes

  1. Introduction to ga.js (Legacy). Google Analytics
  2. Add analytics.js to Your Site. Google Analytics
  3. Measure Google Analytics Events. Universal Analytics
  4. Events. Google Analytics
  5. How to instrument Universal Analytics events as Google Analytics 4 events. Google Analytics
  6. Google Analytics 4 Events. Global Site Tag
  7. Measure Google Analytics Events. Universal Analytics
  8. Automatically tracked events. Analytics Help