In May 2023, companies transitioning from Universal Analytics to Google Analytics 4 (GA4) faced the task of setting up event tracking again. GA4 allows you to create events based on data already collected or send custom parameters through gtag and Google Tag Manager (GTM).
The approaches below come from a guide published in May 2023. Interface section names and platform features are presented as they were at the time.
Which events and parameters does GA4 collect?
The guide lists click, file_download, form_start, form_submit, page_view, scroll, session_start, user_engagement, video_complete, video_progress, video_start and view_search_results as automatically tracked events for websites. Their availability depends on data collection settings.
The parameters GA4 collects by default include page_location, page_referrer, page_title, screen_resolution and language. These may not be enough for more detailed analysis, which is where custom events and parameters can help.
How events work in GA4
When a user takes an action on a website or in an app, GA4 receives a request containing information about that action. In GA4, this data is sent as events; in Universal Analytics, similar requests were called hits. The system then processes and groups the data for reports.
Universal Analytics used four event parameters: Event Category, Event Action, Event Label and Event Value. GA4 does not have this rigid structure: parameters can be chosen to suit the task. This flexibility offers more options for analysis but requires more careful configuration.

Creating an event based on another event
One straightforward option requires no programming. In the Events section, select Create Event, then Create, and specify the conditions under which the new event will be created.

For example, a newsletter_sign_up event can be created based on page_view if the page_location parameter contains the string newsletter-confirmation. The condition should be adjusted to match the subscription confirmation page URL on the specific website.
In the 2023 setup described in the guide, this event could also be marked as a conversion to count subscriptions. This method works when the desired action can be reliably identified from an event and its parameters that are already being collected.
Custom parameters and gtag
To analyze custom parameters, the guide suggests creating custom definitions in GA4. In the interface shown in April 2023, the path was Admin → Property → Custom definitions. After selecting Create custom dimensions, you needed to enter a definition name and event parameter, and select event scope.
For the example of clicks on the main menu, you can send the category Menu Clicks, the selected link’s URL as event_action and its text as event_label. This data lets you compare clicks on menu items, including when their text changes.


When using gtag without GTM, a handler on the site must detect a click on a menu link and send an event, such as menu_clicks, along with the three parameters. This implementation requires basic JavaScript skills. The original guide also suggested using ChatGPT to prepare the code; before adding it to the site, check that it matches the menu markup and that the event works.
Additional parameters can also be sent with a predefined event. For example, the guide gives the sign_up event a method parameter with the value Google and a custom sign_up_plan parameter with the value basic. To analyze the additional parameter, you need to create a corresponding custom definition.
Setting up an event through Google Tag Manager
This method in the guide assumes that GA4 is already installed through GTM and that the required custom definitions have been created in GA4. The example applies to menu links inside an element with the class menu-item.
In Variables → User-Defined Variables, create a variable of the Custom JavaScript type. In the implementation described, it gets the clicked element, looks for the nearest parent element with the class menu-item and returns its class attribute. If no matching element is found, the variable returns an empty value. This helps distinguish menu clicks from clicks on other links.
Next, in the Triggers section, create a Click – Just Links trigger with the Some Link Clicks condition: the class of the element found must contain menu-item. In the Tags section, add a GA4 Event tag with a name such as main_menu_clicks and the parameters event_category, event_action and event_label. Use the built-in variables Click URL and Click Text for the link URL and text, respectively.

Then attach the trigger you created to the tag. Publish the changes and verify that clicks on menu items trigger the event with the required parameters.
Sending events through dataLayer
If a site uses GTM but it is more convenient to implement click tracking in code, the guide suggests using the dataLayer.push() method. In GTM, the event_category, event_action and event_label parameters must be added as data layer variables.
In the example, a handler on the site tracks clicks on elements with the class menu-item and sends the menu_clicks event, the Menu Clicks category, the link URL and its text to the dataLayer. This approach also requires taking the site’s actual markup into account.
How to verify the setup
Checking that the tag fires in GTM is not enough: a configuration error could prevent the event from reaching GA4. Find the event in DebugView and make sure the expected parameters were sent with it.
For a gtag implementation, the guide suggests enabling debug mode using a Chrome extension or the appropriate GA4 configuration setting. Check both the event itself and the values of all custom parameters.
The benefits of flexible configuration
GA4 takes more time to learn and configure than the ready-made event structure in Universal Analytics, but it lets you collect data tailored to specific needs. The guide also notes that a custom definition can be used to store the source of the first visit as a partial way to address changes in attribution models.
Source: https://www.searchenginejournal.com/google-analytics-event-tracking/484607/
Discussion
Sign in or create an account, to join the discussion.