How to track events with Google Tag Manager? - Google Tag Manager for Beginners 2021 | Lesson 9

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i will show you how to track your first event with google tag manager and google analytics [Music] hey my name is julius and welcome to analytics mania youtube channel where you can learn google tag manager and google analytics and if you want to stay up to date with google tech manager consider subscribing this video is a part of video series called google tag manager for beginners so if this is the first video that you're watching i highly recommend to check the description of this tutorial to start from the very first lesson instead in the previous lessons we learned how to create your first tag how to install google analytics 4. this time let's create another tag that will send an event to google analytics 4 after a visitor clicks an important element on a website so let's take a look google analytics 4 already has some built-in link click tracking capabilities and you can find them by going to admin then data streams selecting your data stream i'm talking about website data stream and then in the enhanced measurement section you will find that ga4 is capable of tracking outbound links so this means that a link redirects a visitor to some external website that does not belong to your business and then it also tracks file downloads so if a link contains something like dot pdf dot ppt dot dot x or something else then google analytics four will track that but what if you want to track other links or let's say what if you want to track links and send that information not to ga4 but let's say to facebook pixel or somewhere else in that case enhanced measurement will not help you therefore you definitely need to know and need to understand how link click tracking works in google tag manager and in this video we will take a look at an example where we will be tracking link clicks on these menu items but first let's do one more thing because i just want you to show how link click tracking and google tag manager works in a nutshell that is why just to demonstrate the entire process let's go back to google analytics and temporarily disable outbound link clicks and file downloads in enhanced measurement so once you do that click save and then let's take a look at how can we work with link click tracking in google tag manager so first of all every time you have to track something with google tag manager you have to inspect like what kind of data can you get about that interaction or is google tag magic capable of tracking that interaction at all and to do that we have to enable the preview and debug mode in google tag manager first or if you have already enabled then you should refresh that in both cases you should click the preview button in google doc manager interface since my preview mode was disabled i am asked to enter the url once again and enable the preview mode then you will see that the debugger is connected and that tag assistant in this window is also connected so when it comes to event tracking you have to remember one thing if you want to track a certain interaction and you want to fire a tag based on that interaction for example we will be firing google analytics event tag on link clicks so if you want to do this that particular interaction and in our case that is link click must appear on the left side of the preview mode so if you want to track link clicks first of all that link click somehow must appear right here so let's take a look what happens on the website and let's click on the first link then the second link and then let's say the third link so first of all the page i mean the website reloaded three times and after each click a new page was loaded and if i go to google manager's preview mode what you will see is that we have three new page views so the first page view then the second page view then the third page view however there is no event that says link click and that is a problem because we have to somehow get the link click right here because on that particular link click we will be able to fire our tag and the reason why this is happening is because even though google tag manager is capable of tracking link clicks the link click tracking feature is currently disabled so we have to enable it and to do that we have to go to google tag manager and create at least one link click trigger that will be activated on a page of our sandbox website so we have to go to google tag manager triggers click new trigger configuration and click just links let's keep all these settings as they are because right now we are interested in all link clicks and then let's name the trigger all link clicks click save now let's refresh the premium mode and check whether this trigger has enabled link click tracking capabilities in google tag manager so click preview then i will be asked to enter the url the preview mode has connected now let's try clicking any link and see what happens in the preview mode so let's say that we click home link right here and when i click that i go to the preview mode and what you will see that there is a new page load because after i click the link the page reloaded but also on the previous page view there is a new event that is link click so this link click was possible because google tag manager has now enabled the link click capabilities so that is definitely a good start and if we click this link click right here let's take a look what kind of data about that link click do we have and if we go to variables unfortunately there is nothing related to link clicks right here all we have is the page data like page url page path page domain which is also known as host name all we have is just the event name which is gtm link click so this is a technical name of the link click event but i mean this event name is not enough if we want to distinguish what kind of link click happened because if let's say i click on another link in the footer right here what you will see is that there is another link click event right here and there is almost no difference between these two events so we need to somehow get more data about that link click in order to distinguish what kind of link was clicked was it a menu link was it an outbound link was it something else and if we go to the data layer what you will see that there is actually more information about the link click for example here we have a parameter called element classes which could allow us to distinguish that this link click was made on the navigation link also known as menu link because the other link click contains different values also there is another variable which is element url so this is the url of the clicked link and another link was different so as you can see there is some data but unfortunately we cannot use that data because it is not available as a variable in google tag manager now variable is essential in this case because if we don't have a certain data point as a variable we cannot use it in google tag manager luckily google tag manager has more built in click click-related stuff and if we go to google tag manager to variables and then click configure in the built-in variable section you will find a group of variables that are related to clicks so click element click classes click id click target click url and click text enable all of them because by default they are disabled anyway once you have the click tracking enabled in google tag manager and in this case we are tracking link clicks you also have to enable the variables right here so click classes and so on and now i have refreshed the preview and debug mode so let's click on the first link and let's say the second link and the third link and here we have all these page views and here we have let's say one click the other link click and all of them were made on those particular menu items so let's click any of those link clicks and let's go to variables section and right here we see more variables that we did before so we have click classes click element click id and all the other stuff now some variables have no value because for example in this case menu links do not have a click id on this particular website but we have information such as click text so this is the text of the link so i clicked catalog therefore click text of that particular link click event is catalog then this is the url so if i copy this link of the catalog and paste it right here you will see that the url is connections slash all and this is the exact value that was captured by google tag manager also we have a thing called click classes and here we see that there are some classes added to that particular link now let's click on some other link on a page let's say on search link at the bottom here is another link click event right here and here we see that the click trail is this one click text is this one but there is no click classes then if we click let's say on this logo right here if i click it that was also a link click and if i click then the latest link click right here you will see that the click classes is now different so side header logo link what i'm getting at is that sometimes you can use click classes as a variable to distinguish whether the link click happened on one type of element or on the other type of element so for example in this case i clicked on this element and its class was site header logo link if i clicked at the bottom that link had no class at all now if i click on all of the five menu link clicks right here if i choose the link click right here you will see that the class is site nav laying site nav link main now if i click on another link click the url has changed because here it was catalog link this one is home link some variables are different but click classes are the same so what does it mean that we can use this variable and make our link click trigger more precise because right now we don't want to track all link clicks we just want to track and fire our tag only on those link clicks that are menu links and we can distinguish menu links by the variable called click classes and we can say that if click classes variable contains let's say site nav link main then it means that the visitor clicked a menu link and then we will send that event to google analytics so let's go to google tag manager triggers and then click our existing all link clicks trigger right here then click on the pencil icon right here and choose some link clicks now here we can make our trigger more specific because we want our tag that we are going to create in the near future we want our tag to fire not on all link clicks but on some link clicks where click classes contains site nav link main now copy this exactly because if there are some typos then the trigger will not work and paste it right here and let's rename the trigger to something more specific so let's say link click and menu item or something like that click save now the final part is to send that click information to google analytics so let's say that we will fire a google analytics four event tag when the link click trigger is activated and together with that event we will send the name of the event which can be let's say click and then we can also send the click url and click text together with that event so let's go to google tag manager tags and click new then click tag configuration and select ga4 event because right now we are about to send the event to google analytics for the first thing that we should define is to which exact google analytics property should we send this event because google tag manager does not know that what if you have let's say multiple google analytics four properties configured in the same container well with each tag you have to define to which exact property do we want to send that event that is why i would recommend choosing the ga4 configuration tag that you have already created now what happens here is that this event tag will reuse the settings of this configuration tag and we have already configured i mean we have already entered the measurement id in that configuration tag so instead of manually copy pasting your measurement ids in this tag we are just selecting the existing configuration tag and this event will take those settings all right so i hope that this is now clear and the next step is to add the event name we have to add some meaningful name to this event that follows the rules of google analytics for as you already know there are several types of events in google analytics for including automatically tracked events enhanced measurement events recommended events and custom events so if we want to come up with some meaningful name first we should check what is required by google below this video i will post a link to this page where there are several types of events so let's start with automatically collected events and here we will see a bunch of events most of them are app related but some of them are related to the website as well and we have one event which is called click this is quite generic but if you want you can use that as an event name i mean that is fine however this part is not entirely correct because it says that there are no parameters collected but if we click on this enhanced measurement link you will see that actually there are some parameters that are more familiar to google analytics for so if you want we can actually use these parameters and i mean we can send data to these particular parameters now speaking of event tracking in google analytics 4 there is a lot of flexibility so there is no single correct answer to most of the questions i mean most of the configuration questions if you want you can name the event menu click or menu link click or something else if you want you can send these parameters if you want you can send your custom parameters like menu link click like menu item name or something like that and actually like all of those options will work and as of the moment of recording this video i still haven't chosen like the best option for myself and i'm still constantly experimenting with the setup so let's go to google tag manager and in the event name let's enter click and then in event parameters we might add some additional data we have link classes like i mean like all of these parameters are optional like you don't have to add them but i mean the word click for an event name is quite generic and we would actually benefit from sending some additional data we can send the link url what else do we have here yeah i guess that that works fine you know what actually i think that if i scroll down there is another event which is file download and that file download is using a parameter called link text why not use that one all right so we have parameters now we have to assign some values to those parameters and this is where the power of google tech manager and the real awesomeness comes in because we can actually add some dynamic values right here so for example if i click on the menu item which is blog then we could pass the text of that link which is the word blog in this particular field and in fact we can do that by using variables we already have variables such as click text which returns the text of the link and also we have a variable click url that returns the url of that clicked link so let's do that we can insert variables by clicking this variable button right here so let's start with link url let's click it and let's think about what kind of variable is the best for link url well it is click url because click url variable returns the url of the link that was clicked so let's select the click url right here and then we also have link text link text can use the value of the click text variable right here so let's click the button here and enter click text so what will happen here is that when a menu link click occurs google tag manager will take the text of that clicked link and insert it as a value of this link text parameter and we'll send that to google analytics for now as for link classes we can send this value but it's not very readable why don't we just send some text like menu link click or menu link and we can enter it as a plain word because we know that all menu link clicks have the same click classes value therefore we don't have to insert the actual variable we can just write a word which is let's say menu link so when evister clicks a menu link google tag manager will send an event of which name is click and link classes is just a word menu link and based on the values of click url and click text they will be dynamic so if i click let's say on the home page right here the value of the click url will be this and this value will be sent together with the parameter link url to google analytics for now let's select the triggering condition and we have already created that so click triggering and then select the link click menu item trigger right here the last step is to enter the name of the tag which i usually do like this ga event menu link click let's save this and now we have to test whether this tag fires exactly when we want to so let's refresh the preview mode by clicking the word preview the page has refreshed the preview mode has connected and first let's click on some non-menu link for example on this search link at the bottom then let's click on the link click and we see that no tag has fired well we did not expect any to fire so this is a good sign now let's go and click let's say on the first menu item then on the second menu item then let's say on the third menu item but let's wait first while the debugger loads here it is so now i made three link clicks let's go to the preview mode and see what is happening here so here is the link click and on this link click i see that my tag has fired let's click it and you will see what kind of information was sent if you want to see the actual value of the click url you can just switch to values right here and you will see what was sent so it was an event with the name click and then there were some parameters also in this tag we can see the firing trigger section where we see what kind of conditions were met and which trigger activated so in this case our attack has only one trigger and obviously all of these conditions were met so we were looking for a link click event and we were looking only for that particular event and i mean link click where click classes variable contains this value and if we switch to values once again you will see that this is the value of click classes and this is the value that we were looking for and this green check mark shows whether the condition was met and it obviously was the final thing that we need to do is that we need to go to analytics and check whether the incoming data is actually received so let's go to the debug view of google analytics for and here you will see that there are some events so we have some pageviews we have some clicks so let's click on this click event and here we will see parameters such as link classes so this is menu link then link text then link url so it looks like everything is working properly i will not be showing how to do that because you already know but if this was a real project then you could now submit your changes and publish this container live awesome you have made it till the end of this tutorial now you have a better understanding of what gtm is how does it work and how to create your first setup however keep in mind that this is just the beginning of your journey there are still many things that you need to learn about google tag manager if you want to get some additional details i have a free ebook which is called google tag manager for beginners you will find the link to that ebook below the video it contains some additional tips that were not mentioned in this video also if you want you can check my premium google tag magic course for beginners this video that you're currently watching explained around 15 of what a beginner should actually know about google tag manager the rest 85 percent are explained in my course which is called google tech manager masterclass for beginners i will post the link below the video to learn more if you found this video useful hit the thumbs up button because it helps me continue working on this channel and that's just how youtube algorithm works so i mean i have to play by the rules and if you want to get more tips in the future consider subscribing my name is julius this is analytics mania and i will see you in the next [Music] video [Music] you
Info
Channel: Analytics Mania - Google Tag Manager & Analytics
Views: 4,377
Rating: undefined out of 5
Keywords: google tag manager for beginners 2021, google tag manager course, google tag manager tutorial, gtm tutorial, gtm for beginners, introduction to google tag manager, google tag manager tutorial 2021, what is google tag manager, google tag manager free tutorial, digital analytics, learn google tag manager, google tag manager setup, google analytics 4 event tracking, google analytics event tracking button click, google tag manager google analytics, google analytics 4 click tracking
Id: w1jIO-WNPOA
Channel Id: undefined
Length: 21min 3sec (1263 seconds)
Published: Tue Mar 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.