• Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login
  • Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login

April 21, 2022

How to Track Custom Events with Google Analytics 4

Updated: April 21st, 2022. Google Analytics 4 definitely has a steep learning curve. If you compare it to Universal Analytics, there are many differences and event tracking is one of them. In one of my previous blog posts, I explained how GA4 event tracking works in general. But if you are interested in learning just how to track custom events with Google Analytics 4, you have come to the right place.

In this blog post, I’ll explain how to do that with Google Tag Manager.

 

Table of Contents

+ Hide table of contents +

  • An in-depth guide about event tracking in GA4
  • Video tutorial
  • GA4 Event tracking in a nutshell
  • Example: Menu Link Click
  • IMPORTANT: Register custom definitions
  • Test your custom events
  • Where can I find custom events in GA4 reports?
    • “Reports → Engagement → Events” report
    • Exploration reports
  • Turning Google Analytics 4 Custom Events into Conversions
  • Want to learn more about event tracking in GA4?
  • Final Words

 

An in-depth guide about event tracking in GA4

Custom events are just a part of all possible events that you can track with Google Analytics 4. If you want to learn the full story, go to this blog post with an in-depth video.

 

Video tutorial on how to track custom events with Google Analytics 4

If you prefer video content, here’s a tutorial on my Youtube channel.

 

GA4 Event tracking in a nutshell

If you want to learn the full context of event tracking in Google Analytics 4, read this tutorial. It also includes a detailed video tutorial.

Things like event category, action, label are no longer available in Google Analytics 4. Instead, GA4 introduced a very flexible data model that allows you to structure your events in any way you want.

There are 4 event types in Google Analytics 4:

  • Automatically collected events
  • Enhanced Measurement events
  • Recommended events
  • Custom events

The process of how you should plan the structure of your events (names and parameters) is by doing the following:

  1. Check if the event that you want to track is among the automatically collected events
  2. If not, then check if your event is mentioned among the Enhanced Measurement events (e.g. scroll or file_download)
  3. If not, then check the recommended events and their naming convention
  4. If none of the above categories apply to your events, create a custom event with an event that you want

In this blog post, we will focus on the 4th type, custom events.

The configuration of Custom events is pretty much identical to recommended events. The only difference is that you will need to come up with your own event names.

For example, if you want to track form submissions of a contact form, the name of the event can be any of these:

  • form_submission
  • contact_form
  • contact_form_submission

Or anything else.

GA4 is completely flexible here. However, there are some limitations when it comes to the maximum length of an event name.  Also, there is a limit of 500 unique event names per GA4 property. If you reach it, Google says that you won’t be able to track any other new events. And at the moment, you cannot delete unused events (which is unfortunate). Therefore, be careful about creating too many unique event names.

Update: the “500 unique event names” does not apply to web events. Learn more

Maybe in the future, this situation/limitation will change. Who knows.

So, speaking of the custom event tracking, let’s look at the example where we want to measure clicks on menu links on a website.

 

Example of a Custom Event in GA4: Menu Link Click

Note: menu link click tracking trigger conditions differ on most websites (because of different click classes, IDs, etc.). Try to do your best to apply this example.

On a demo website, I have several menu links that I want to track.

First, I need to create a trigger with correct conditions that distinguish any click from a menu link click. Enable Google Tag Manager’s Preview mode and try clicking any of the menu links on a website. Once you do the first link click, you should see the Link Click event in the Preview mode’s left sidebar.

If you don’t see it, you should:

  • have at least one Just Links GTM trigger activated on a page
  • or have “File download” or “Outbound links” tracking enabled in your Enhanced Measurement Settings

Let’s say, that you don’t use Enhanced Measurement in GA4. Go to Google Tag Manager > Triggers > New > Just Links. Keep the trigger set on “All link clicks” and save the trigger.

By creating this trigger, we will enable the link-tracking functionality in Google Tag Manager.

Then go to Variables > Configure (in the “Built-in Variables” section) and enable all Click-related variables.

Refresh the preview mode (by clicking the Preview button once again).

Then go to your website and click any of the menu links. Actually, click at least two of them. Return to the preview mode and you should start seeing Link Click events in the preview mode. Click the first Link Click event and go to the Variables tab of the preview mode.

Then click on the second Link Click event. I am currently looking for some variable that I could use to distinguish a menu link click. I don’t want to fire my GA4 event tag on any link click. I want to fire it precisely on a menu link click.

After taking a closer look, I see that both links contain the same Click Classes value, site-nav__link site-nav__link–main. By the way, nav means “navigation” in this context. Great! I will use this in my Just Links trigger.

Go back to the list of triggers in your GTM container and click the previously created trigger for All Link Clicks. We’ll edit it and add a condition: Click Classes contains site-nav__link–main

Save the trigger. Now, it’s time to create a Google Analytics 4 event tag. Go to Tags > New > Google Analytics: GA4 Event. Select your existing GA 4 Configuration tag and then enter the event name. Its value is up to you. Any of the following options are perfectly fine:

  • menu_click
  • menu
  • menu_item_click
  • menu click
  • etc.

These are just some of the examples. Since we are working with a custom event, we can name it whatever we want (as long as we follow the limitations of name length, for example).

In my case, I used menu_click event name. But this time, sending just the event name is not very useful. You’d probably want to know which exact menu items are clicked more often. How about we also send the name of the menu item and the URL?

We could do that by sending additional event parameters. Even though you could use parameters that are already mentioned in the documentation of the Enhanced Measurement (like link_url and link_text), let’s create two custom parameters (because I just want to show you how to configure them).

I am going to pass two parameters, menu_item_url and menu_item_name. I made these parameter names up and you can do it too. That’s what the flexibility of the data model offers.

To send custom parameters, you must expand the Event Parameters section in the Google Analytics 4 event tag and then click Add Row.

Enter the name of the first parameter. In my case, that is menu_item_url. In the Value field, I will insert a variable that returns a clicked URL. Luckily, GTM already offers such a variable, it’s called Click URL. Click the Insert Variable button and then select the {{Click URL}} variable.

Let’s add another parameter, menu_item_name. For that purpose, GTM offers another built-in variable, {{Click Text}}. Insert it as well. Since visitors of your website can translate your page, {{Click Text}} value will also change, hence you will see a more diverse list of collected values in your GA4 reports.

If you want to send more parameters, you are free to do that. You can send up to 25 custom parameters with a single event.

Assign the previously created Just Links trigger to this tag. Save the tag. Refresh the GTM Preview mode and click a couple of your menu items. Go back to the Preview mode and click those Link Click events. Check if the GA4 event tags for Menu Link Clicks have fired.

menu link click event in google analytics 4

Now, you will need to go to Google Analytics 4 and check the DebugView. You will learn more about that in this chapter of the blog post.

IMPORTANT: even though you will see your custom parameters in Real-time reports and DebugView in GA4, you will not be able to see them in other GA4reports. Unless you register those parameters as custom dimensions in Google Analytics. Read the next chapter of this blog post.

 

 

IMPORTANT: Register custom definitions

This applies to any custom parameter that you send to Google Analytics 4. If you want to see/use them in things like Funnel reports, Exploration, see their reporting cards in standard reports, etc., you must register custom parameters in the GA interface.

In Google Analytics 4, go to Configure > Custom Definitions. Since we sent 2 custom parameters with the menu link click, we must register them both here.

Click the Create Custom Dimensions button and then enter:

  • The name of the parameter. You can enter whatever you want. This is just how the dimension will be displayed in your reports. You can name it “menu_item_url”, “Menu item URL”, or anything else.
  • Scope. Since we want to apply this parameter only to one event (and not to all events of the same user), we need to select Event
  • Event parameter. This is where you have to enter its name precisely as you entered it in the GTM tag. If your parameter name is menu_item_url, you must enter it here exactly like that. Don’t worry if the autocomplete feature of that field does not show your parameter yet. Just enter it and save the dimension

Then register a second parameter (in my case, that was menu_item_name) and save it. By the way, I sometimes use the words “custom parameter” and “custom dimension” interchangeably. In general, custom metrics and custom dimensions are both grouped as custom parameters.

And now we wait. Within the next 24 hours, the custom parameters will start appearing in your Google Analytics 4 reports.

 

Test your custom events in Google Analytics 4

Once you configure your custom events, it’s time to test them. The primary feature built for debugging GA 4 data is the DebugView section. You can find it by going to Configure > DebugView.

That’s the place where your debugging should take the place. Do not mix this with the GTM Preview and Debug mode. They are two different beasts.

To enable the debug mode in GA4, you have several options (any of them will work):

  • Enable the GA debugger Chrome extension
  • Send a debug_mode parameter together with an event
  • Have enabled Google Tag Manager’s Preview mode on a page that you’re debugging

In the case of the first option, install the extension here, and then click its icon (so that you can see the ON ribbon). From this moment, you will start seeing your events coming into the DebugView.

The other option is to send a debug_mode parameter with every event that you wish to see in the DebugView.

In Google Tag Manager, you can do that by opening the GA4 Configuration tag and adding the following parameter:

If the debug_mode parameter is set to true, the event will be seen in DebugView. If you are using a hardcoded gtag.js, here are the instructions on how to include the debug_mode parameter.

But since we are working with Google Tag Manager, having the GTM Preview mode enabled automatically sets the debug_mode to true, thus the data will start appearing in the GA4 DebugView.

When you start seeing data in the DebugView, you can click on every individual event and then a list of parameters will be displayed.

Click on that parameter to see the value that was received by GA4. Now that is some granular debugging!

However, I have noticed some delays between the event actually happening on a website and then appearing in DebugView. Sometimes, I have to wait for several minutes until the events come in. That’s a bit unfortunate and hopefully, the team behind Google Analytics 4 will improve this in the future.

Also, make sure that you have selected the correct Debug device in the top left corner.

If multiple visitors have enabled the debug view (e.g. they all have enabled the Chrome extension), you will see multiple devices there and it might require some time to find yourself. This especially applies to my blog, when many of my readers have enabled the GA Debugger Extension and I have to guess which device (out of the other 15) is mine 🙂

Anyway, once you start seeing data in DebugView, things will look like this.

Events are marked with blue icons, conversions with green. Please ignore the fact that I treat menu_click events as conversions. This is just for demonstration purposes 🙂

If you click the event, you will see the parameters that were sent together with an event. Click on the parameter to see its value.

Once you made sure that the data is coming in and it is displayed properly, you should submit your GA4 changes in the GTM container and publish it.

You can do that by clicking the SUBMIT button in the top right corner and then complete all the other steps that the user interface asks you to do.

After that, you should soon start seeing the new data coming in your real-time reports as well.

On the left sidebar of the Google Analytics 4 interface, go to Realtime. This is where you will see the data coming into your reports. Unlike in the previous version (Universal Analytics), the new report offers you the capabilities to see the data on a much more granular level.

First, you will see a map and a bunch of cards with traffic sources, most popular events, the number of users in the last 30 minutes (by the way, Universal Analytics real-time report shows the number of users in the last 5 minutes).

You can also take a look at the snapshot of an individual user. You can do that by clicking the View user snapshot button in the top right corner.

Then, you will see a stream of all events of that particular user, you can click on them (just like in the DebugView) to see things on a more granular level. If you wish to look at another user/visitor, you can click the button here:

To exit the snapshot, simply press the Exit snapshot button in the top right corner.

 

Where can I find custom events in Google Analytics 4 reports?

This blog post focuses mainly on the tracking of custom events with Google Analytics 4. I will not dive deep into how to find insights, raise questions, answer questions, etc. However, I can show you several places where you can find the event data that you have just sent to Google Analytics 4.

Keep in mind that at the moment of writing this blog post (late 2020), the built-in reporting capabilities of Google Analytics 4 are still quite limited. Hopefully, that will change soon. Let’s take a look at what we have now. Here are some of the reports:

  • Configure > Events (this will show just the list of events with counts. Nothing fancy.
  • Reports > Engagement > Events
  • Explore (a.k.a. Exploration reports)

But that is not all. Since GA4 is an event-based analytics platform, every report is affected by events that you send (in one way or another). The aforementioned reports are just the most notable examples.

 

“Reports → Engagement → Events” report

This is an overview of all events that were sent to your property + a couple of charts. Below them, you will see a list of events and if you click on any of them, you will take a closer look at that event’s data.

 

Explore (a.k.a. Exploration reports, ex Analysis Hub)

This is the place where you will be able to drill-down into your data. In the Exploration, you will be able to use reports such as Free Form, Funnel Exploration, Path Exploration, etc.

Here is an example of a Free Form report. Keep in mind that you will need to wait for up to 24 hours for the data to come into your reports. So if you don’t see the data now, be patient.

Let’s say that I want to see how different device categories are interacting with the menu bar of my site. Remember, I set up the menu_click event?

So, let’s go to Explore and click on the Free Form block.

Then in the Variables column, I need to include the menu_item_url custom dimension because I want to see how many clicks did get each menu URL. Click the Plus icon and then find the menu_item_url dimension. Select it and it will be included in the list of possible dimensions in the report.

If you CANNOT see the menu_item_url (or whatever custom parameter are you looking for), you must register that custom parameter in All Events > Manage Custom Definitions. And then wait for 24 hours until the data appears in the reports. If the reports don’t work properly, wait for even longer.

Then let’s edit the Tab settings. Remove the existing dimensions in the ROWS and include the custom definition that you want to include. In my case, that’s menu_item_url.

In the COLUMNS section, I used the Device category dimension. In the VALUES section, select the metric that you wish to see. I used the Event Count.

Then you will need to filter only to those events that actually contained the menu_item_url dimension. In my case, that is just a menu_click event. That’s why at the bottom of the Tab Settings section, you should enter a filter: Event name exactly matches  menu_click.

That’s it, your report will now display how different device categories are clicking menu items; which ones are the most popular and how many times were they clicked.

Also, don’t forget to change the date range if you need it. You can do that in the top-left corner of the Exploration interface.

You can also use event data in things like funnel reports, but let’s keep it for another tutorial (hopefully) in the future.

 

Turning Google Analytics 4 Custom Events into Conversions

Not all events are equal. Some are more important for businesses. In the previous GA version, the most important interactions were called goals. Now, they are called conversions (which is a widely-known term if you have ever worked with other marketing/analytics tools).

If you want to learn how to configure conversions in Google Analytics 4 (because the process is very different compared to Universal Analytics), watch the video tutorial below or read this in-depth blog post:

 

Want to learn more about event tracking in Google Analytics 4?

Honestly, in this video, I was just scratching the surface of what you should know about event tracking. If you want to learn more, head over to this blog post. In it, you will find topics like:

  • How to plan your event structure
  • Automatic event tracking
  • Recommended events in Google Analytics 4
  • How to create custom events directly in Google Analytics 4 interface
  • How to modify events directly in Google Analytics 4 interface
  • and more!

 

Tracking Custom events with Google Analytics 4: Final Words

To sum up, here’s is the recommended process of how you should track events with Google Analytics 4 (and you can learn more about it here):

  • Check the automatically tracked events and what Enhanced Measurement has to offer.
  • If an event (that you wish to track) is not listed there, check the recommended events and try to use their naming recommend names and parameters.
  • If none of the recommended events match your need, then create a custom event in Google Analytics 4 (and the entire blog post was just about this part)

Here are some of the key takeaways:

  • No more Event Category, Event Action, Event Label fields. If you want, you can create them manually as custom parameters but that does not make sense.
  • You can send custom parameters (dimensions and metrics) with events (both recommend and custom).
  • You can send up to 25 parameters with a single event.
  • If you want to see a parameter in the GA4 report, you must register it as a custom definition. There is a limit of 50-registered custom dimensions and 50 registered custom metrics per property.
  • Use Google Analytics 4 DebugView to test the incoming events on a granular level.

Got more questions about tracking custom events with Google Analytics 4? The comments section is at your service

 

Julius Fedorovicius
In Google Analytics Tips
22 COMMENTS
Raimundas
  • Nov 29 2020
  • Reply

Hello Julius,

I tried to set up meniu link click tracking, but in the preview mode "Click Classes" value equal - ". As you mentioned in the article it should have some differentiator like in your example - "site-nav__link site-nav__link–main". But in my case, the value is - ". So how should I get that differentiator? Should web developer to set up it?

    Julius
    • Nov 29 2020
    • Reply

    Ask a developer. Or learn CSS selectors

      Raimundas
      • Nov 29 2020
      • Reply

      Thanks!

      Bernie
      • Mar 16 2022
      • Reply

      Thank you SO much! This was extremely helpful.

Deepak Kumar
  • Nov 30 2020
  • Reply

Hi Julius, thank you for this walk through. I was able to replicate it for my client and event tracking is working perfectly fine.

Di Prima
  • Dec 7 2020
  • Reply

Hi Julius,

Thx for your explanations. It's very useful ! Keep going.

I have a request for you. I try to find a way to combine click event & element visibility event.

I track clickable slides in a hp slider. I track clicks by slide with a custom events that contains the name of the slide, the position... The reports works well in GA4. But i would like to go further and add true view parameters to have the number of views by slide in addition in my analytics report (to calculate the CTR).

I've tested the element visibilty on another element and i get the number of time this element is visible on the page. So i would like to have that data for my slide.

Do you know if it's possible to combine events for the same element in tag manager and ga ?

Here is my slide code :

Tag Manager test

Thx in advance.

Amelia Jacob
  • Dec 8 2020
  • Reply

Hey Julius,

Great blog! You explained it very well. It really helped me in my project.

Thank you.

Pete
  • Dec 14 2020
  • Reply

Hey Julius,

just wanted to thank you for such a clear and concise blog. I'm a complete novice as web dev and associated analytics, but thanks to your various blogs I've been able to bumble my way through to having some insight on what is happening on my site.

explaining complex things to a novice so they can understand them is a sign of a true master.

thank you

Jet
  • Dec 23 2020
  • Reply

Hi Julius,

Thank you for your amazing guide.

I'm wondering if I can still see the old data if I register the custom parameter after a while the associated events have been recording.
E.g. I started recording events and the corresponding parameters in Oct, but I only enable the custom parameters on GA4 UI in Dec. Can I still see the custom parameter data of Oct and Nov on the report?

Thanks a lot.

    Julius Fedorovicius
    • Dec 23 2020
    • Reply

    Hi, you won't be able to see the parameter in GA4 reports before it was registered

      Jet
      • Dec 23 2020
      • Reply

      Hi Julius, thank you for your prompt reply. And the old data won't be backfilled even the events and associated parameters have been recording before the registration on GA4 UI, right?

      Thanks a lot.

Jet
  • Dec 23 2020
  • Reply

Hi Julius, thank you for your prompt reply. And the old data won't be backfilled even the events and associated parameters have been recording before the registration on GA4 UI, right?

Thanks a lot.

Ashish
  • Jan 21 2021
  • Reply

Hi Julius,

I am trying to track phone number click for my client in GA4 by using google tag manager but the event parameter which I set is not working correctly while tag configuration. Please suggest the event parameter to track phone number link click.

Thanks in advance.

Manjunath S A
  • Dec 28 2021
  • Reply

Hello Julius,

Thank you for your wonderful guide.
I had created custom events in GTM, I am able to track them in configure section of Google analytics platform after submitting the GTM container, but these events are not visible in Engagement section of GA4 even though the time constraint has passed 24 hours+, please help me with this issue?

Sagarbhatt
  • Feb 9 2022
  • Reply

Sir thank you very much for all your content it is helping me a lot. I am a big fan of your content. I kindly request you to please share a blog or your views on how to do social tracking using google analytics 4. As researched a lot about this topic but I am unable to find any relevant content regarding the same. It will be a great help thank you very much.

Patrick Wolf
  • Mar 5 2022
  • Reply

Hi, thank you for the very interesting post. We use GTM and both a normal GA property and now a GA4 property.The GA4 property is linked to the GA property (as far as I can see). I then setup GTM with the GA4 event tag and in GA4 I can see in the DebugView that data for an event has been transmitted. However, when I switch to "Configure" and click on "Events" none of my custom events is shown in the "Existing events" table. By contrast, the message "Integrate the SDK or set up tagging to start getting event data. You'll see your first event reports here within 24 hours." is displayed here. When I click on "Modify event" I can see my two configured custom events, but they are not listed in the overview table as mentioned before.

Do you know why this message appears? The GA property stream is configured as Webstream.

    Julius Fedorovicius
    • Mar 5 2022
    • Reply

    Hi, your question contains the answer. 24 hours.

akmal sulton
  • Apr 26 2022
  • Reply

something is wrong here, it is not possible to track clicks on the banner

rob
  • May 5 2022
  • Reply

what if you have been tracking event through code and not GTM, does the code change at all? would it still be going to GA4? Thanks!

Ryan
  • May 13 2022
  • Reply

Hi Julius,

I'd love to see an updated version of this.
The report section seems to have changed a lot since 2020.
Filters don't seem to be present in the tab settings of free form reports.

Thanks for your work.

Alex Homsi
  • May 20 2022
  • Reply

I am trying to modify outbound clicks that have link domain for social media.

I have it as the following

Modification name
instagram_social_click_type

Matching conditions
Modify events that match ALL of the following conditions

matching condition

Parameter Operator Value
event_name equals click

Parameter Operator Value
link_domain contains (ignore case) instagram.com

Parameter New value
click_type social

It used to work but now it seems like it is not working any ideas?

Tomasz
  • Jun 2 2022
  • Reply

Hello, Im struggled with configuration of transaction value at GA4. I've already done with Event configuration "Purchase" but I can not set a transaction value for it to measure e-commerce.
Can You help me?

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
  • RSS feed
Recent Posts
  • Two Link Click Events in Google Tag Manager Preview Mode
  • Where to Find Video Engagement Data in Google Analytics 4?
  • Where to Find File Download Data in Google Analytics 4?
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings