How to set up event tracking in Google Analytics 4

Google Analytics 4 (GA4) is a new resource created by Google to replace Universal Analytics. GA4 is already the default Google Analytics installation. Therefore, it’s important for anyone working with analytics to understand its new data model. In this article, we’ll examine the structure and operation of events in GA4. We’ll also use an example to show how to configure GA4 using Google Tag Manager (GTM).

Event structure in Google Analytics 4

GA4 no longer has the “Category,” “Action,” “Label,” or “Value” components. They have been replaced by:

  • An event is a user action on a website or in an application during a specific time period. Old parameter in Universal Analytics is related to<event_name> in GA4;
  • Parameters are additional information that describes the event: when and where it occurred.

Event construction

gtag(‘event’, ‘<event_name>’, {
‘<parameter_1_name>’: <parameter_1_value>,'<parameter_2_name>’: <parameter_2_value>,'<parameter_3_name>’: <parameter_3_value>,});

GA4 has “Automatically logged events” and “Enhanced statistics” which<event_name> predefined by the system. There are also “Recommended” options, which offer standardized names and parameters.

You can also give events your own (special) names.

Page_view is a classic page view in GA4. It launches automatically after installing the counter on your site and cannot be disabled.

By default with<page_view> Google collects the following additional parameters:

  • page_location;
  • page_path;
  • page_title;
  • page_referrer (URL of the previous page).

Event restrictions

The following restrictions on data collection have been established:

And there are such settings limitations:

Event Types in Google Analytics 4

There are four types of events in GA4:

  • Automatically registered;
  • Recommended;
  • Special;
  • Improved statistics.

Unlike Universal Analytics, where events had to be configured using the global site tag <gtag.js>or GTM, in GA4 many events are recorded automatically.

Automatically logged events

With “Basic Data Collection,” GA4 automatically tracks a specific set of events. This includes events for both apps and websites. It also lists events from “Enhanced Insights.”

List of automatic events that are not in other event categories:

  • first_visit — when a user visits a site or launches an application for the first time;
  • session_start — when a user visits a website or launches an application and begins interacting with it;
  • user_engagement – Fires periodically when the user has launched and/or is in the open application.

They can be seen in the Real-Time report:

Improved statistics

Statistics help marketers independently obtain more events in reports without additional communication with developers or settings in GTM.

The Enhanced Measurement section is located in the window at the following path: Admin — Data Streams — Select the web data stream.

By default, Enhanced Statistics is enabled and tracks the following events:

  • page view (event name: page_view);
  • scroll(event name: scroll);
  • click on an outgoing link (event name: click with the outbound: true parameter);
  • site search (event name: view_search_results);
  • video engagement (event name: video_start, video_progress, video_complete);
  • file download (event name: file_download).

For more information, see Google Help.

These events can be enabled or disabled individually. To do this, click the gear icon in the “Enhanced Measurement” section:

Select the events you need:

Some events can also be customized. Let’s take a closer look:

  • page_views

Sent to GA4 when a new page is loaded or the page URL changes without reloading it:

  • scroll

Sent to GA4 once per page when a visitor scrolls below the 90% height threshold.

  • click

Used to track outgoing link clicks. It sends an additional parameter, “outbound” (with a value of “true”), along with several other parameters: link_classes, link_domain, link_id, and link_url.

If you have multiple domains, go to the “More Tagging Settings” section in the same stream -> “Configure your domains” and enter them. Any domains listed here will not trigger the event. via outgoing link.

  • view_search_results

Sent to GA4 when the URL of the loaded page contains a query parameter. For example: q, s, search, query, keyword. There can be up to 10 of these, separated by commas:

For example:

If the URL of the search results page looks like this: https://netpeak.net/ru/blog/search/?q=ga4, then in “Settings” you should enter “q” (without quotes).

If the search results page URL looks like this: https://site.com/search/?key=search+term&results=50, then enter “key” (without quotes) in the first configuration field and “results” (without quotes) in the second. GA4 will automatically track this parameter:

  • video_start, video_progress, video_complete

Enhanced Insights can track engagement of embedded YouTube videos on your site and then send events<video_…> in GA4.

To enable this, the URL of the embedded YouTube video player must contain the ?enablejsapi=1 parameter. However, this feature isn’t always available. There are other reasons why YouTube video tracking may not work. Therefore, it’s best to configure this event separately through GTM.

  • file_download

Sent to GA4 when clicking a link (open/download file) that contains one of the following file extensions: pdf, xls, xlsx, doc, docx, txt, rtf, csv, exe, key, pps, ppt, pptx, 7z, pkg, rar, gz, zip, avi, mov, mp4, mpe, mpeg, wmv, mid, midi, mp3, wav, wma. It is not yet possible to update the list with other extensions in the GA4 interface.

Once you’ve selected the events you want to track, click “Save” in the upper right corner. Then, make sure “Enhanced Measurement” is enabled.

From this point on, Google Analytics 4 will automatically begin tracking events that will appear in the Real-Time report:

You can view all events in the “Engagement” – “Events” section. Clicking on an event name will display all its parameters:

The list of “Improved Statistics” events can also be seen in the “Events” – “Existing events” section:

Featured Events

Before setting up, when choosing a name and parameters for an event, check if it’s listed in “Automatically collected events” and “Enhanced Measurement.” Only then should you proceed to the “Recommended events” list.

We’ll create our own “Recommended Events” using standard names and parameters. This will allow us to work with existing and future reporting features that aren’t available for events with custom names.

Google has created “Recommended Events” for these types of activities:

Some of them already existed in Google Analytics for the default gtag.js library with defined categories and labels:

For example:

  • To track when a user logs in, we use an event< login> from the “All resources” list;
  • To track when a user shares content from the site, we use from the “All resources” list.

Using recommended names helps Google Analytics better understand your data and use it for machine learning.

Special events

When the event we want to send is not mentioned in “Automatically tracked”, “Enhanced statistics”, or “Recommended events”, we create our own (special) events.

To create special events you need to:

  1. Log in to your Google Analytics account.
  2. Select the required resource.
  3. On the left panel, select “Events”.
  4. Click “Create Event”.

  1. Select an existing special event or create a new one using the “Create” button:

  1. Configure the custom event settings as shown in the screenshot and click “Create”:

You can access these settings in another way. Select “Administrator” – “Resource” column – “Data Streams” – “Sites” – “Web Stream” – “Advanced Tagging Settings”:

Event names may only contain letters, numbers, and symbols. Underscores and spaces are prohibited. The name must begin with a letter, and the letter is case-sensitive. This means that events with names And – different.

Important: Google has limitations , such as the total number of characters for special names. Additionally, each GA4 property is limited to 500 unique event names. Once the maximum is reached, the system will prevent new events from being tracked and will not allow unused ones to be removed. Therefore, avoid creating too many unique names.

Examples of event names for tracking clicks on a call-to-action button:<call_to_action> or<cta_click> .

An example of setting up an event in Google Analytics 4 via Google Tag Manager

GTM has two types of tags for collecting data in GA4:

  • Google Analytics: GA4 Configuration. Sets basic settings and is used as the base configuration for event tags.
  • Google Analytics: GA4 Event. Used to send events to GA4.

Before setting up tracking, let’s set up the GA4 configuration.

Adding Google Analytics 4 code to GTM:

1. In GTM, in the “Tags” tab, click “Create”:

2. From the suggested options, select the tag “Google Analytics: GA4 configuration”:

3. We write down the “Data Stream Identifier” from GA4.

To do this, go to GA4 settings: “Administrator” – “Data Streams” – “Web Stream Details”:

Copy it and paste it into the “Data Stream Identifier” line in the “Tag Configuration” window:

4. Select the “All Pages” trigger:

5. Enter the tag name and click the “Save” button:

Setting up tracking:

In GTM, go to the “Tag Configuration” window. In the “Tag Type” line, select “Google Analytics: GA4 Event.”
Select the previously created “Configuration Type” with the data flow identifier “GA4”:

Enter a name. For example, we need to track how many people signed up for a course and clicked the “Done” button on a friendly website:

Remember, you can’t use names from “Automatically Tracked.” Let’s come up with a name like “Enrollment”:

Since we’ve chosen a one-page website, we’ll specify the additional condition “Once per page” in “Tag activation settings”:

In “Event parameters,” add the parameters you want to send along with the event to GA4.

The parameters specified in the “Configurations” tag at the time of activation are enabled automatically.

Important: If you want to use parameters in reports, you must register them as custom parameters.

We specify which element was clicked:

Set the “Activation Trigger”: “Click” – “All Elements”:

To track a click on this particular button, you need to specify the condition:

  • find the desired element on the page;
  • Inspect the element in the browser using the developer console: press F12, right-click on the desired button (in this case, it is “Done”):

  • In the “Menu” select “View code”:

In this example, “Form Classes” contains “ninja-forms-field nf-element”:

We enter the trigger name and click “Save”:

Enter the tag name in the upper right corner (in this example, “Event Button”) and click “Save”.

Testing Events in GA4

You can check the operation of events in GA4 using:

  1. Real-time report.
  2. DebugView.
  3. Extensions for the Google Chrome browser – Google Analytics Debugger or its equivalent.

Let’s test our event using DebugView. To do this, install the Google Analytics Debugger extension—when enabled, the icon displays “ON”:

  1. Go to the website you’re monitoring. A Debugger login window appears at the bottom.

  1. Enter the website address and click “Start.” “enrollment” repeated 20 times:

  1. The DebugView report will display the login and all completed events on a timeline. In our case, an event named “enrollment” was displayed, repeating 20 times:

By clicking on a name in the list of main events, we see all its parameters and properties:

Remember

  1. The Google Analytics 4 data model is event-based only.
  2. The event structure in GA4 differs from Universal Analytics. Instead of four components (“Category,” “Action,” “Label,” and “Value”), there are only two: “Events” and “Parameters.” The event structure has also changed.
  3. There are four types of events in Google Analytics 4:
  • automatically registered;
  • recommended;
  • special;
  • improved statistics.

GA4 is still in its infancy—we expect new features to appear soon.

Source: Netpeak.net

Scroll to Top