How to Set Up Event Tracking in Google Analytics 4

news

Google Analytics 4 (Google Analytics 4, GA4) is a new resource created by Google to replace Universal Analytics. Already, when installing Google Analytics, GA4 is used by default. Therefore, it is important for everyone who works with analytics to know what kind of data model it has now. In this article, we will look at the structure and operation of events in GA4. Let's use an example to show how to set up GA4 through Google Tag Manager (GTM).

Event structure in Google Analytics 4

GA4 does not have Category, Action, Label, Value components. They have been replaced:

  • an event is a user action on a site or in an application in a certain period of time. Old setting in Universal Analytics correlates with in GA4;
  • parameters are additional information describing the event: when and where it happened.

Event Construction

gtag('event', ' ', {
' ': <parameter_1_value>,' ': <parameter_2_value>,' ': <parameter_3_value>,});

GA4 has "Automatically Logged Events" and "Enhanced Statistics" in which predefined by the system. There are also "Recommended", which offer standardized names and parameters.

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

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

By default with Google collects the following additional parameters:

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

 

Event limits

The following data collection restrictions are set:

How to Set Up Event Tracking in Google Analytics 4 1

And there are the following settings restrictions:

How to Set Up Event Tracking in Google Analytics 4 2

Event Types in Google Analytics 4

There are four types of events in GA4:

  • automatically registered;
  • Featured;
  • Special;
  • Improved statistics.

Unlike Universal Analytics, where events had to be configured using a global tag or GTM, in GA4 many events are registered automatically.

Automatically logged events

In Basic Data Collection, GA4 automatically tracks a specific set of events. It contains events for both applications and sites. Events from the "Improved Statistics" are also listed there.

List of automatic events not found in other event categories:

  • first_visit - when the user visits the site or launches the application for the first time;
  • session_start — when the user enters the site or launches the application and begins to interact with it;
  • user_engagement - periodically fires when the user has launched and / or is in an open application.

You can see them in the Real Time report:

How to Set Up Event Tracking in Google Analytics 4 3

Improved statistics

Statistics help marketers get more events in reports on their own without additional communication with developers or settings in GTM.

The “Enhanced Measurement” section is located in the window along the path: “Administrator” - “Data Streams” - “Web Stream Details” (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);
  • following 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).

More details - in Help from Google.

These events can be disabled and enabled individually. To do this, click on the gear icon in the "Enhanced Measurement" section:

How to set up event tracking in Google Analytics 4 4

Select the events you need:

How to Set Up Event Tracking in Google Analytics 4 5

Also, some events can be configured additionally. Let's consider in detail:

  • page_views

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

How to Set Up Event Tracking in Google Analytics 4 6
  • scroll

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

  • click

Used to track the transition on an outgoing link. Along with it, an additional outbound parameter is sent (with the value "true") and a number of such parameters: link_classes, link_domain, link_id, link_url.

If you have multiple domains, go to More Tagging Settings - Configure your domains in the same flow and enter them. All domains listed here will not trigger the event outbound link.

How to Set Up Event Tracking in Google Analytics 4 7
  • view_search_results

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

How to Set Up Event Tracking in Google Analytics 4 8

For example:

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

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

How to Set Up Event Tracking in Google Analytics 4 9
  • video_start, video_progress, video_complete

"Enhanced Statistics" can track the interaction of embedded Youtube videos on your site and then send events

To do this, the URL of the built-in Youtube video player must contain the parameter ?enablejsapi=1. But this feature is not always available. There are other reasons why Youtube video tracking might not work. Therefore, it is better to configure this event separately through GTM.

  • file_download

Sent to GA4 when clicking on 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.

When the events to track are selected, click "Save" in the upper right corner. Then make sure "Enhanced Measurement" is enabled.

From now on, Google Analytics 4 will automatically track the events that will be displayed in the Real-time report:

How to Set Up Event Tracking in Google Analytics 4 10

You can view all events in the Engagement - Events section. Clicking on the event name will show all its parameters:

How to Set Up Event Tracking in Google Analytics 4 11

The list of "Enhanced Statistics" events can also be seen in the "Events" - "Existing events" section:

How to Set Up Event Tracking in Google Analytics 4 12

Featured Events

Before setting up, when choosing a name and parameters for an event, check if they are in the "Automatically registered events" (Automatically collected events) and in Enhanced Measurement. Only then go to the list of "Recommended events" (Recommended events).

We create "Recommended events" ourselves, using standard names and parameters. Then we will be able to work with existing and future reporting features that are not available for events with special names.

Google has created "Recommended Events" for the following activities:

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

How to Set Up Event Tracking in Google Analytics 4 13
For example:

  • to track when a user logs in, use an event from the list "All Resources";
  • to track when a user shares content from a site, use from the All Resources list.
How to Set Up Event Tracking in Google Analytics 4 14

Using recommended names helps Google Analytics better understand the data and apply it to machine learning.

Special events

When the event we want to send is not mentioned in either "Auto Tracked", "Enhanced Statistics", or "Recommended Events", we create our own (special) events.

To create custom events:

  1. Sign in to your Google Analytics account.
  2. Select the required resource.
  3. Select "Events" on the left panel.
  4. Click "Create Event".

 

How to Set Up Event Tracking in Google Analytics 4 15

5. Select an existing special event or create a new one using the "Create" button:

How to Set Up Event Tracking in Google Analytics 4 16

6. Set the parameters of the special event as shown in the screenshot and click "Create":

How to Set Up Event Tracking in Google Analytics 4 17

You can access these settings in another way. Select "Administrator" - "Resource" column - "Data Streams" - "Sites" - "Web Stream" - "Additional Tagging Settings":

How to Set Up Event Tracking in Google Analytics 4 18

Event names can only contain letters, numbers and symbols. Underscores and spaces are not allowed. The name must begin with a letter, which is case sensitive. That is, events with names And - different.

Important: Google has restrictions, for example, the total number of characters for special titles. In addition, there is a limit of 500 unique event names per GA4 resource. When the maximum is used, the system will not track new events and delete unused ones. So don't create too many unique names.

Examples of an event name for tracking clicks on a button with a call to action: or .

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

There are two types of tags in GTM for collecting data in GA4:

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

 

How to Set Up Event Tracking in Google Analytics 4 19

Before setting up tracking, we set up the GA4 configuration.

Add Google Analytics 4 code to GTM:

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

How to Set Up Event Tracking in Google Analytics 4 20

2. From the proposed ones, select the tag "Google Analytics: GA4 configuration":

How to Set Up Event Tracking in Google Analytics 4 21

3. We prescribe the "Data stream identifier" from GA4.

To do this, in the GA4 settings, go to "Administrator" - "Data Streams" - "Web Stream Details":

How to Set Up Event Tracking in Google Analytics 4 22

Copy it and paste it into the "Data Stream ID" line in the "Tag Configuration" window:

How to Set Up Event Tracking in Google Analytics 4 23

4. Select the trigger "All Pages" (All pages):

How to Set Up Event Tracking in Google Analytics 4 24

5. Enter the name of the tag and click the "Save" button:

How to Set Up Event Tracking in Google Analytics 4 25

Set up tracking:

In GTM, go to the "Tag Configuration" window. In the "Tag type" line, select the type "Google Analytics: GA4 event".
We select the previously created "Configuration Type" with the data flow identifier "GA4":

How to set up event tracking in Google Analytics 4 26

We enter the name. For example, we need to track how many people signed up for a course and clicked the "Done" button on the friendly site:

How to Set Up Event Tracking in Google Analytics 4 27

Remember that you can not use names from "Automatically tracked". We come up with the name "Enrollment":

How to Set Up Event Tracking in Google Analytics 4 28

Since we have chosen a one-page site, we specify the additional condition "Once per page" in the "Tag activation settings":

How to Set Up Event Tracking in Google Analytics 4 29

In the "Event Parameters" add the parameters that we want to send along with the event to GA4.

The parameters specified at the time of activation in the "Configurations" tag are included automatically.

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

We write down which element was clicked:

How to Set Up Event Tracking in Google Analytics 4 30

Set the "Activation Trigger": "Click" - "All elements":

How to Set Up Event Tracking in Google Analytics 4 31
How to set up event tracking in Google Analytics 4 32

To track a click on this particular button, you must specify a 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”):
How to Set Up Event Tracking in Google Analytics 4 33
  • in the "Menu" select "View Code":
How to Set Up Event Tracking in Google Analytics 4 34

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

How to Set Up Event Tracking in Google Analytics 4 35

Enter the name of the trigger and click "Save":

How to Set Up Event Tracking in Google Analytics 4 36

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

How to Set Up Event Tracking in Google Analytics 4 37

Checking the operation of events in GA4

You can check the operation of events in GA4 using:

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

Let's check the operation of our event through DebugView. To do this, install the Google Analytics Debugger extension - when enabled, the icon displays ON:

How to Set Up Event Tracking in Google Analytics 4 38
  1. We go to the monitored site. At the bottom, the Debugger login window appeared.
How to Set Up Event Tracking in Google Analytics 4 39

2. Enter the site address and click "Start".

How to Set Up Event Tracking in Google Analytics 4 40

3. The DebugView report will display the input and all committed events on the timeline. In our case, an event called "enrollment" was displayed, repeating 20 times:

How to Set Up Event Tracking in Google Analytics 4 41

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

How to Set Up Event Tracking in Google Analytics 4 42

Remember

1.Google Analytics 4 data model is based on events only.

2. Structure of an event in GA4 is different from Universal Analytics. Instead of four components (“Category”, “Action”, “Label”, “Value”), it has only two: “Events” and “Parameters”. The design of the event 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 are waiting for the appearance of new features in the near future.

 

A source: Netpeak.net