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!
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:
- first_session (when a visitor lands on the website for the first time)
- session_starts (every time a new session starts on the website)
- 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?
- First, go into Google Analytics and click on Configure on the sidebar. Then, at the bottom of the page select Admin.
- Select Data Streams from the menu and choose your website.
- 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.
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.
- Open Google Tag Manager and click on Variables.
- Once in Variables, click Configure and ensure that the Clicks are selected.
- 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.
- Return to your website in Preview mode, and click the button you want to track. For me, I clicked on the LinkedIn button.
- 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.
- 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’.
- 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.
- Go to Tags and New, then select Tag Configuration.
- 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.
- Select the trigger previously made, then select save. Your event is officially set up!
- 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:
- Go onto Google Analytics, and select Configure and Custom Definitions. After, create a new Custom Dimension. I named my dimension the LinkedIn button.
- 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.