How to set up event tracking using Google Analytics 4 and Google Tag Manager

How to set up event tracking using Google Analytics 4 and Google Tag Manager

7th September 2022

Soon we will be saying farewell to Universal Analytics and making way for Google Analytics 4; with just over a month to go (July 2023) – now is the perfect time to brush up on some Google Analytics event tracking skills. Google Analytics 4 is the ideal tracking tool for beginners since the software has some built-in measurements, meaning no need to configure them yourself! 

Showcasing Google Analytics 4 at Bopgun

If Dexter can do it, anyone can!

So what is an event, and why track one?

An event can be any activity on your webpage, for example, when someone clicks a link or scrolls down a page. Event tracking on Google Analytics is very beneficial for seeing how users approach your website, thus helping marketing strategies. 

Similarly to Universal Analytics, GA4 includes some of the basic Automatically Tracked Events. These are: 

  1. first_session (when a visitor lands on the website for the first time)
  2. session_starts (every time a new session starts on the website)
  3. user_engagement (fires when a visitor spends at least 10 seconds on a page and then goes onto another page on the website).

An exciting new feature included in GA4 is Enhanced Measurement. Turning this on is simple and allows you to track events on your webpage without configuring them. 

How to set up Enhanced Measurement?

  1. First, go into Google Analytics and click on Configure on the sidebar. Then, at the bottom of the page select Admin.Step one of setting up Enhanced Measurement in Google Analytics 4
  2. Select Data Streams from the menu and choose your website. Step two of setting up enhanced measurement in Google Analytics 4
  3. Then this menu will show with the option to turn on Enhanced Measurement. There’s also the option to turn off individual measurements by selecting the settings button on the right. Step three of setting up Enhanced Measurement in Google Analytics 4

 

Press save, and now your website is tracking some helpful events; in just a few clicks! But what if you want to be more specific with your tracking? Intrigued by how many people click on your social links? The Custom Events option allows you to track almost anything!

Generously, Google also introduced Recommended Events: a selection of worthwhile custom events to track based on your company’s needs. These are readymade with a parameter but have to be configured yourself.

 

How to configure a custom event on Google Analytics 4 using Google Tag Manager?

In this guide, I used Google Tag Manager to incorporate events into Google Analytics 4. In my example, I set up a Custom Event tracking the number of clicks received on our LinkedIn button.

  1. Open Google Tag Manager and click on Variables. Step one of setting up a custom event in Google Analytics 4
  2. Once in Variables, click Configure and ensure that the Clicks are selected. Step two of setting up a custom event in Google Analytics 4
  3. Next, exit out of this and click Preview in the top right corner and insert the URL of your website. Now Tag Assistant is connected.
  4. Return to your website in Preview mode, and click the button you want to track. For me, I clicked on the LinkedIn button. 
  5. Go to Tag Assistant, and on the sidebar, there should be a Link Click, the button you have just pressed in the Preview. Go to Variables. Since I want to track the number of clicks, I have copied the section by Click Classes. I have highlighted this below. Keep this copied. 
  6. Return to Google Tag Manager and click on Triggers on the sidebar, then New to configure a new trigger. Our trigger type will be ‘Click – Just Link’.’ Since I only wanted to track the LinkedIn link, I have also selected ‘Some Link Clicks’.
  7. Now select Click Classes and paste in the section we previously copied. Mine looked like the image below. I have named mine GA4 LinkedIn but call your trigger whatever fits your event. Make sure to save this.
  8. Go to Tags and New, then select Tag Configuration.
  9. When selecting the ‘Tag type’, click ‘Google Analytics: GA4 Event’ (you must configure GA4 before if you haven’t), then click your GA4 configuration tag. The value should be ‘Click URL’ since we are tracking when users click our LinkedIn link.
  10. Select the trigger previously made, then select save. Your event is officially set up!
  11. To double-check this, exit your previous Preview Session on Google Tag Manager and open a new one. Click your button and watch it fire in Tag Assistant!

 

How to create a Custom Dimension in Google Analytics 4?

So that your new event shows up in your reports on Google Analytics, you must create a Custom Dimension.  This is a simple step but crucial to ensure the event is visible in your data! To do this:

  1. Go onto Google Analytics, and select Configure and Custom Definitions. After, create a new Custom Dimension. I named my dimension the LinkedIn button.
  2. Return to Google Tag Manager and our LinkedIn tag, copy the Parameter name and paste it into our dimension on Google Analytics under the Event parameter and save.

All done! Don’t worry if you can’t see your event on Google Analytics instantly; it may take up to 24 hours for the data to show.

If you need a hand setting up custom event tracking in Google Analytics 4, don’t hesitate to get in touch.

 


Sky-rocket your insights by reading our blog on the secrets behind a great website.