How to Track Events with Google Analytics 4 (Updated in 2022)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
unlike in previous versions google analytics 4 offers built-in event tracking capabilities called enhanced measurement but what if you want to track some additional events in this video we will take a look at how to track events with google analytics 4 and google tag manager [Music] hey my name is julius and welcome to the analytics mania youtube channel where you can learn google tech manager and google analytics and if you want to be up to date with ge4 then consider subscribing to this channel by default google analytics 4 is capable of tracking scrolling outbound link clicks searches and several other events but you should not limit yourself just to those events for example did you know that built-in scroll tracking in google analytics 4 tracks only those interactions where visitors scroll below 90 of the page height but what if you want to track other thresholds as well for example 25 50 75 and what if you want to track custom events like form submissions logins or others for that you will need to use google tag manager or gtag.js in this video i will be using google tag manager but below this video you will find a link to another tutorial where i show some event tracking examples with gtag in this video i presume that you have already installed google analytics for if you haven't yet then take a look at the description of this video where i will share a link to a blog post and a video tutorial that explains how can you do that in this video i'm going to cover the following topics first of all we will take a look at the automatic tracked events then we will take a look at the enhanced measurement which is also part of the automatic tracking but it tracks some additional events that were not available in universal analytics for example such as clicks scrolling and so on then we will take a look at some recommended events so if you want to track something that is not automatically tracked then there is a list of events that google's recommends you to implement if you have some event in mind and that one is not mentioned among recommended events then you can send them as custom events and then this video will be ended with creating new events directly from the interface of ge4 and how to modify your incoming events because sometimes events might contain certain errors and the fastest way for you to do that might be using the modify events feature so when you install google analytics 4 by default it will be able to track certain events speaking of website events here they are let's start with first session so this event is fired when you land as a visitor on your website for the first time ever then there is session start so this event is automatically tracked every time a new session starts in google analytics 4. by default session duration is 30 minutes so if let's say you as a visitor land on a website in the morning and then later on that very same day you land on a website let's say in the evening it will start a new session and then there is user engagement event there are more nuances about this event so if you want to learn more i will post a link to a blog post below this video but in general this event fires when a visitor spends at least 10 seconds on a page and goes to another page of your website when it comes to mobile app tracking there are more automatically tracked events and if you want to learn more about them i will also post a link below the video now let's move to the enhanced measurement you can find its settings by going to your google analytics for property then clicking on admin then data streams and then selecting your website data stream and here you will see the enhanced measurement section where you can see what kind of events are tracked automatically if you want you can disable this feature altogether by clicking this toggle button or you can disable them one by one or maybe even configure something by clicking this gear icon pages are always tracked automatically so you cannot disable them but if you want you can also track things like scrolling so if a visitor scrolls below the 90 of the page height then an event called scroll will be dispatched and tracked by google analytics 4. then there is outbound click tracking so if a visitor clicks a link on your website and that link opens a website that belongs to another domain then you will get a click event and you will also be able to see what kind of link was clicked then there is site search so if your website has a search feature and your website has something like search and then my keyword for example then google analytics 4 can be configured to track this parameter and display and reports this particular keyword so you will be able to know what kind of things are your visitors looking for on our website if you click show advanced settings you will see the default parameters that are automatically recognized by google analytics for but if your website is using something else then you can add them with a comma so for example if your website is using something like search results this will be recognized by google analytics for and then there is video engagement events so this applies to embedded youtube video players on our website but it is important to know that those websites must have an additional parameter included in the code of the video player in order to google analytics 4 to recognize those video interaction events if you want to learn more about that parameter you can click this link and finally there is file downloads so if you have some links on your website and those links open let's say pdf files maybe word files excel files then google analytics 4 will track a file download event and together with that event you will also see what kind of link was clicked that way you will be able to recognize what kind of files are clicked the most often speaking of file downloads here are supported file types maybe in the future this list will be extended but right now as of the moment of recording this video they are supported by ga4 let's take a look at how those events are tracked and how that data is displayed in google analytics 4. here i am on a demo website and on this website i have installed google analytics for with google tag manager so this means that google tech manager's code snippet is added to the source code of the website and then i created one tag which is google analytics for configuration tag this is the measurement id of my data stream that is right here so when the stack fires it will enable enhanced measurement and i will start seeing some events and let's say debug view of google analytics 4. so let's enable the preview mode of google tag manager i will do that by clicking the preview button then i will copy the url of the page then i will paste it right here click connect and then i will go to the debug view of google analytics for so let's go to ge4 then configure then debug view and here i should start seeing some events like pageview for example now let's scroll to the bottom of the page then let's go back to google analytics for debug view and here i should also expect to see an event which is called scroll because i have passed the 90 of the page height and here is that event if i click it one of the parameters will be percent scrolled and it will be 90 because that's how this event works it fires only when i scroll below the 90 of the page height please ignore these parameters because this is my test property and these are inherited from my previous tests so in your case you won't be seeing this now let's take a look at some other examples for example here i have outbound link click tracking page so this is a link that belongs to another domain this is one domain and this link will open my analytics mania website so if i click it then in the debug view i should see an event called click and here's that event if i click it i will see certain click data like link domain so this is the link of the url that i clicked then the actual full url then outbound if it is true then it means that the link belongs to another domain that is not part of your business now speaking of where can you see that data in google analytics for interface there are several places but keep in mind that when you start sending data to ge4 it takes for up to 24 hours to display that data in actual interface so don't expect real time or near real-time display of the data so one of the places where you will see event data is in the events section under the configure so this is just a list of events that were tracked by google analytics for this will include enhanced measurement events custom events recommended events and basically everything that you send to ga4 then you can go to reports and in the engagement section click events and here you will see some information about your events but basically you will see just the name of the event and if you click let's say on scroll you will see a closer look at that event but if you're setting some additional parameters with the event and those parameters are not custom dimensions then you won't be able to see them right here maybe in the future this will change but right now if you want to access some parameters about the events you will need to create custom reports so go to explore then let's say freeform and then let's create a report with outbound link clicks so in the dimensions we have the event name but we also want to know the actual url that was clicked and that dimension is called link url if you want to use some dimension in the report you have to add it to the variables column first so in the dimensions section click plus and then in the search field look for the link url click checkbox then import and now it is available right here now let's remove the predefined options that are city and device category and instead in the rows let's add the link url because we want that each row would be a separate link url so now once i added it i see that the first item is empty that is because right now we're looking at all events that happened on a page and obviously not all events were link clicks so we have to narrow down and in the filters section click anywhere and then say that we want to look only at those events where event name exactly matches well file download i don't see that because still not enough time has passed so maybe let's try another event because i know that i have definitely tracked that in the past and that is outbound link click so instead of event name exactly matches file download let's just use click then apply and also we can select let's say last three months and since this is a demo property and not a lot of outbound link clicks per click i see only one row anyway if i had more data and if i had more outbound links on the page then i would see that each row is a separate outbound link speaking of metrics right now i see only active users but if i want to see how many times each event was clicked i could add another metric which is event count and now we see that this link was clicked three times in the last three months if you are curious what other dimensions are available when it comes to enhanced measurement you can take a look right here so click dimensions plus and then enter for example video so these parameters are related to enhanced measurement then we have link and then you see these parameters then i think there is also scroll so percent scrolled then when it comes to site search so the parameter is called search term and that's it now let's move to another category of events which is recommended events if you want to track events such as purchase or add to cart you will notice that they are not tracked automatically and this is logical because websites are coded in different ways they store data in different structures therefore it is nearly impossible for google analytics to automatically track such information since google analytics 4 is quite flexible you can send any event names that you want or parameters however if your event falls under a certain recommended event naming convention then i would recommend that you do that and you follow those recommendations so if you want to find out what kind of events are recommended in google analytics 4 and i mean naming convention and data structure just go to google search and enter ga4 recommended events and then you should find the official documentation of ga4 click that link and here you will see a list of various events for example here we have things like sign up so if you have a registration form on your website then it is recommended to track the sign up event then we have login purchase and if you want you can click on a particular event and this will redirect you to a developer documentation where you can see parameters their format and also their descriptions below the table you will see a sample code snippet if you decide to use gtag to implement event tracking instead of google tag manager but if you have watched other videos on my channel you know that i'm a big fan of google tech manager so let's try to track one of the recommended events and let's see how can we do that with gtm so first of all i will go back to the list of all recommended events and on my demo website i have this fake login page so when i enter username and password i will then be redirected to my account so if you go to the recommended events you will see that one of the events right here is login i can click it and there is one parameter which is optional because in the required column you see no so if you want you can send this if you don't then you can skip this and in the context of login method might be the way how the user logged in to your website maybe you have just one login method which is email and password but also maybe you have login with google or login with facebook or maybe some other login method and if you have multiple options and you want to see which options are used the most often then you can send this parameter together with the login event so now let's check what is happening on the login page i have enabled my google doc manager preview mode and i have asked a developer to push the login information to the page that comes after i successfully log in so i will enter something like let's say test.test.com and like this i click login and then here it says you have logged in obviously again this is demo page so i don't have anything meaningful right here but then in the preview mode i have an event login so this is what i have asked my developer to push the data layer and then i click on login and i can expand this data layer push and here it is it says event login and user id is one two three so this would be useful if i decided to implement user id tracking with google analytics for but this is a topic for another video so let's ignore this right now what is important for us right now is just the fact that login occurred and if the next time i log out out of my account and log in again your developers coach once again push that login to the data layer if you have no idea what data layer is then i have some introduction video and i will post a link to it below the video so if we want to send the login event to google analytics 4 we have to go to gtm then in the tags section click new click on tag configuration and then click ga4 event if you have no idea what eagle tech manager is and you want some introduction then i have a tutorial about it and you will find a link to it below the video here we should select our existing google analytics for configuration tag because this tag will inherit certain settings of this configuration tag for example measurement id so when this tag fires google tech manager will know to which exact property should we send this event and in the event name field we should enter the name that is mentioned in the documentation of google analytics for recommended events and that event is well login so let's enter login and then in the triggering section we have to configure when exactly do we want this tag to fire and in our case that is when login is pushed to the data layer in google tag manager conditions are called triggers so in the triggering section let's create a trigger that will mean that we want to fire on this login data layer push in google tag manager let's click triggering and then click the plus icon and then click on trigger configuration because right now we are going to create a new trigger or in other words the condition when the tag is supposed to fire click anywhere then click custom event and here we should enter the same name that we see right here or right here so login without quotation marks log in then i will name it for example like this here you can enter whatever you want but here it must be exactly login because it is login right here and then click save this trigger was automatically added to a tag so when a login event appears in the data layer this tag will fire and google tag manager will send the login event to google analytics 4. let's name this tag g4 event and login click preview here i am on the login page and i will enter my login info and click login then i go to the preview mode and i click on the login event and here i see that my google analytics 4 tag has fired now let's check if the data has actually received google analytics for so let's go to ga4 configure debug view and here i should expect to see the login event and here it is login event so far so good now let's do another thing let's say that we have multiple login methods on our website so what we could do that we can send together with a login event the parameter method let's do that here i am in the google analytics for event tag that i have previously created and let's add an additional parameter and we can do that by clicking event parameters section click add row and here you should enter the parameter name that you see right here so method all lowercase method and here if i had some login method information in the data layer i could insert a variable of google tag manager that dynamically returns the value of the method but since i don't have that let's say that this tag is responsible only for the email login so i will just send the word email let's test how this method is displayed in the debug view i will click save refresh the preview mode by clicking the preview button then click continue and then log in i have logged in here is the login event the tag has fired and if i click on that tag i can switch between names and values and here we can see what kind of information was sent to google analytics now let's check ga once again the debug view and see if we see that information in the debug view and here it is login i click on it and there's also a method parameter which says emails so i as a visitor have logged in via my email and password if you want to start seeing this method dimension in reports such as exploration you will have to register it as a custom dimension because by default at least right now it will not be displayed in the interface even after 24 hours i mean you see it right here but you won't be able to use it in other parts of the interface so to do that you will have to go to custom definitions then in the custom dimensions section click create custom dimensions and here you should enter something like method then in the event parameter field you must enter method exactly like this because this is the value that we saw in the preview mode and in the debug view the scope must be event because this parameter is applied to a single event description can remain empty and then click save so after you implement your event tracking and after you create this dimension then you will need to wait 24 hours and from that moment you will start seeing this dimension in your reports also don't forget that when you properly test your setup you will need to publish these changes live so that other visitors will also be tracked with google analytics 4 and you can do that by clicking the submit button then entering the version name and hitting publish and now let's take a look at custom events if you want to track some event and you cannot see anything in the recommended event list then you're free to come up with your own name or parameter let's say that on my demo website i want to track when someone clicks on any of these menu items and i want to have a dedicated event for that let's say that i will call it menu link click now if you go to the list of recommended events you won't find anything related to that that is why i just can come up with my own name so first let's check how can we configure a trigger in google tag manager i have already enabled the preview mode and now i will click a bunch of links and i do that by holding the ctrl key in order to open those links in a new tab so this one this one this one i think three are enough and now let's go to the mode of google tag manager and here i have three links this is the first link the second link and the third link now let's go to the data layer and i see some information about the link click this is the url or in other words a click url that was clicked another url another url and we have some additional information right here however if we want to use it in google tag manager we must have them as variables but if you go to variable section right here you won't find anything related to clicks so to do that you have to go to google tech manager variables and we have to enable built-in click variables so we can do that by clicking configure and then click check boxes next to all click variables right here well actually i had click id enabled but we have more options right here also if you don't see the link click events in your google tag manager container you then should create at least one link click trigger in your container so you should go to triggers new for your configuration and then just links don't change anything and then name it something like all link clicks the reason why i saw the click event even though i didn't have the trigger created is because i have enabled enhanced measurement in google analytics for so because of some technical nuances enhanced measurement makes the link click events available in the google tag manager preview mode so once i have created the trigger the variables i click preview to refresh the preview mode and let's click the links once again i will click this one then this one this one and then in the preview mode let's click on the link click event right here and in the variable section we have that click information right here none of the links has the click id so that is unfortunate then click element if you are a beginner that is too advanced for you so don't try to use something like click element contains and something something because that will not work instead what we can take a look at is the click classes variable because right now we're looking for a way of how to identify that the link click happened not on any link but on the menu item if i click these three events i will see that their click classes is the same and that click class is site nav link nav in this case means navigation or in other words menu if i click let's say on other link like on this name of the site and then i check that link click its class is different so i could say that if link click occurs and click classes contains site nav link it could be my condition to send an event to google analytics 4. so i have copied this site nav link by the way keep in mind that every website is different so in your case the class names might be different there might not be even any classes at all so click tracking is sometimes quite tricky and it depends on many things but in my case i'm quite lucky because click classes is unique enough now let's go to google tech manager and i already have created a link click trigger if you haven't yet then again click new then trigger configuration just links and since i already have that i just click this one and i will make it more precise instead of tracking all link clicks i will track only navigation link clicks so i click some link clicks click classes contains and this one and now this trigger is not for all link clicks it is just for those link clicks that are of the menu item so click save and now let's create a tag because when a click on the menu item occurs i want to send an event to google analytics 4. i can do that by going to tags clicking new tag configuration and then ga4 event again i select my g4 configuration tag and here we have to enter some event name as i've said before there is nothing related to menu link clicks in the list of recommended events that is why i will just come up with my own event name which is menu link click and then together with that event i could send some additional parameters because i want to know what kind of menu item was clicked so i could say something like menu item name and menu item link maybe i don't know something like that right now coming up with some made up parameters and they will work in google analytics for if i configure them properly so if you come up with some parameter that you want to use in google analytics for you are free to do so however keep in mind that later you will need to register them as custom dimensions and there is a limit of 50 custom dimensions per ga4 property first of all if you want to send some custom parameter you have to enter it in the parameter name right here and then you need to enter value so when it comes to item name i could say that the click text would be enough for me in fact if i go to the preview mode then i select one of those menu link click events i will see that click text contains the actual text of the url of the link so i could use click text as the value of my menu item name i can insert that value by clicking this button and then entering click text so it means that when this event occurs google tag manager will replace this part with the actual value of the variable that was at that particular moment so when on this event attack fires the value of the variable will be subscribe on this event it will be gtm course oh sorry no this one is unrelated because this will not be tracked because of the different class but in this case it will be blog in this case it will be home and in the menu item link value we could insert another variable which is click url it will return the actual url of the link that was clicked so we can do that by clicking the lego button right here and then choosing click url in the triggering section let's select the condition when we want the stack to fire and we want to do that every time a link is clicked right here and luckily we have already created a trigger for that so in the triggering section click anywhere and then select that link clicks menu trigger and that's it so now let's name this tag i usually name them like that event and then the name of the event and click save now let's test this with google tag manager click preview now let's click on the first link let's say on fourth link the fifth link then i go to the preview mode and i see that if i click on this link click the attack has fired it fired successfully the same happened right here so the attack fired three times in total i mean this tag and now let's go to the debug view of google analytics four so in the configure click debug view and here we can see menu link click events right here i can click on it and among some automatically tracked parameters i can also see the menu item link and menu item name parameters but you won't be able to use them in the interface of ge4 unless you register them as custom dimensions because these are definitely custom they are not mentioned anywhere in the documentation of google analytics 4. so to do that we have to go to custom definitions and while being in custom dimensions section click create custom dimensions and then enter some descriptive name that you want to see in your reports for example menu item link then scope should be event and then in the parameter field we must enter exactly as it is right here which is menu item link we want to tell google analytics for that menu underscore item underscore link is our custom dimension that we are going to register right here so menu item link click save and then do the same thing for another parameter which is menu item name so create custom dimensions menu item name scope again event and then menu item name click save when you do that and then when you publish your google tag manager changes you will need to wait for up to 24 hours after that time passes then you will start seeing the dimension in your google analytics for interface for example you will be able to use that in explorations you will be able to see that in the reports so for example in the reports you will start seeing well we should go to the engagement and event and in this list here you will start seeing menu link click if you don't see it then you should show more rows per page for example 100 and when you click on that menu link click i see it right now because in the past i have also sent the event with the same name and here you will see some additional widgets well right now i don't see them because i haven't registered to the dimensions before but here you will see some additional widgets and tables that will contain information about these two custom parameters menu item name and menu item link because you have registered them as custom dimensions and that is how you can track custom events with google analytics 4. the next two features that i want to quickly review are related to event tracking configuration but that configuration is done not in google tag manager but in ga4 and that is create new events or modify events both features can be found in the configure then events and here you will find modify event and create event so create event allows you to create an event based on another incoming event in google analytics for for example by default google analytics is capable of tracking page views but what if some pageviews are more important let's say you have thank you page since google analytics 4 is an event-based tool and a lot of emphasis is put on events and their names what you could do that you could create another event name that is called thank you page view and that way when you log into your google analytics 4 report you will quickly see the total number of page views and also the number of thank you page view visits so here is a quick process of how can you do that click on create event then click create and here you should enter the new name of the event that you want to track so for example as i've said it can be thank you page view or something like that and now you have to configure when should this event be automatically created in google analytics form and we can enter something like this every time event name equals to page view make sure it is with underscore and all lowercase because that is the name of the event that is tracked automatically by ga but in this case we want to be more specific we are looking only for certain page views and we can add another condition where page location contains let's say thank you because that is part of the url of our thank you page so if a visitor lands on a page this event is dispatched and its url contains this part we will have one more event in google analytics 4 that will be named like this and this will happen every time this condition is met and also with this event we have all the parameters that were available in the pageview event as well because this checkbox is created click create and that's it so if you had this page on your website you could now visit that site and then open the debug view of your google analytics four and together with that pageview event you will also see thank you page view event another reason why this is useful is because you could now mark this particular event as a conversion and you could do that by going to conversions in the configure section click new conversion event and then just enter the name of your newly created event so every time a visitor lands on a website a regular pageview event will be fired but when your visitor goes to your thank you page another event will be created and that will be thank you page view and it will be also marked as a conversion or in other words as a more important event in your tracking setup so then you can click save and within 24 hours after you start collecting some data and your visitors land on that thank you page you will get some information right here and now let's take a look at the modify event feature so let's say that i have a situation where i'm tracking when a visitor adds payment method at the checkout now the problem with that event is that it is not named properly so if i go to the debug view in my case i will see that there is an event but it is called add payment info and we have uppercase a p and i now the problem with this is that in the list of recommended events ad payment info is a lower case google analytics 4 and javascript in general is case sensitive so it means that ad payment info with lower case is not with the upper case therefore some reporting might be off in my property so what could i do is obviously the first option could be to ask a developer to fix this because let's say that this code is not coming from google tech manager so that i could fix it it is coming from the hard-coded snippet but also let's say that in this situation the developer is not available but i have to find some quick fix soon so what could i do that i could use the modify events feature and i could rename this event in order to make it proper and in order to follow the documentation of google analytics for so i could do that by clicking modify event create and then i need to give some name for this modification so let's say that i will name it like add payment info fix and then now i have to enter some condition when i want to apply this modification so in my case it should be if event name equals at payment info then i want to modify a parameter which is also event name so instead of add payment info with uppercase letters i will change it to add payment info just as it is mentioned in the official documentation of ge4 click save and now let's see how this works so let's say that right now i have added payment info on my demo page so now i should go to the analytics and debug view under the configure tab right here and here i should expect to see ad payment info not with uppercase a p and i but with all lowercase letters and here it is modify event feature fixed my problem if i click on this event i will see that there's a parameter that is called checkout option and it looks like it is also incorrect because c and o are uppercase so we can go and further improve our modification so go to events modify event then add payment info fix and then we can modify additional parameter that is checkout option because it is a lowercase and we want this new parameter to reuse the value of that checkout option that we had in the debug view so now i will duplicate the debug view so that we could easily compare the data i will go to the debug view and then add payment info so what are we going to do is that it is not easy to rename the existing parameter instead i will create a new parameter with the correct name and then i will remove this checkout option so now i'm going to create a new parameter which is the correct checkout option and i can dynamically insert the value of this parameter and i can do that by entering the original name of the parameter but it should be surrounded by double square brackets like this so after we create this new parameter we have to remove our existing incorrect parameter which is this one and that can be done just by entering the parameter name in this field without any additional symbols and we should leave this field empty so it means that this will be removed let's save and let's see if this worked so now i will pretend on my demo page that i have once again added payment info and now let's see what we have in the debug view here's the ad payment info and here we have checkout option which is all lowercase which is correct and its value is still paypal so we have created a new parameter and we have removed the incorrect one and that is how you can track events with google analytics 4 and google tag manager there are really cool capabilities in the interface for example the ability to modify events or create new events based on other events since ga4 is event based these features definitely make sense if you found this video useful hit the thumbs up button below the video because it helps me continue working on this channel also if you want to learn more about google tag manager or google analytics 4 then consider subscribing to this channel my name is julius this is analytics mania and i'll see you in the next video [Music] you
Info
Channel: Analytics Mania - Google Tag Manager & Analytics
Views: 94,314
Rating: undefined out of 5
Keywords: google analytics, google analytics 4, google analytics 4 tutorial, track events with ga4, ga4 event tracking, google analytics 4 event tracking, google analytics 4 events, google analytics 4 custom events, google analytics tutorial 2022, google analytics 4 event reports, track google analytics 4 events, google analytics 4 recommended events, google analytics 4 enhanced measurement
Id: RyoMaZ51agA
Channel Id: undefined
Length: 38min 35sec (2315 seconds)
Published: Tue Feb 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.