How to Track Outbound Link Clicks with Google Tag Manager (updated)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
In this video, I'm going to show you how you can track external link clicks with the help of Google Tag Manager and forward this information on to Google Analytics. All and more coming up. Hey there measuregeeks, Julian here. Back with a another video for you. Today, we are answering a question from our MeasureMaster Tom. If you don't know what MeasureMasters is, it's our premium membership community. You want to check it out down below, we'll have a link. Well Tom asks, how can he track his affiliate link clicks on his website with the help of Google Tag Manager? Well, this is really the external link click methodology of tracking links with the help of Google Tag Manager. Then you can forward this information onto Google Analytics or your facebook pixel or your Google Ads tag in order to this be your goal or retargeting audience. With Google Tag Manager, we can do this pretty easily because there's a built in functionality and actually there's something new in this technique that was announced a little while ago. And now it makes it even easier to track outbound link clicks. So without further ado, let's dive in and see how we can track external link clicks with GTM. Alright, to get started, we have here our demo shop where I have already Google Tag Manager installed. And we now want to pick up any kind of external links that the user clicks on. So we're not talking about internal links, like to this blog post right here, but rather external link clicks, such as we have, for example, here to wordpress.org. This go outside of our domain and it would be a good idea to know which links to user clicks in order to leave our page. So you might want to optimize this, but it might also have another purpose. For example, if we have an affiliate product in our store on our blog posts, such as this one, we want to know how many people clicked actually on this link to go to our partner store. And then we track this with the help of Google Tag Manager and Google Analytics. So let's get started. In our Google Tag Manager, to start tracking links, we need to have a trigger setup. So let's go over to the trigger section here, and click on new. And this will be a generic link click trigger. Why do I say generic? Because we are going to just deploy the listener functionality to see if it actually works. And then later, we will specify to only track certain clicks. So let's proceed with the trigger configuration. We click on the field and choose the just links option right here. Now, you might be tempted to use all elements. But this wouldn't detect the actual link in the background. So when the user leaves the page, and therefore we need to use to just links click trigger. We leave all the configuration untouched for now, and just save this. Now that we have this installed, we go into the preview and debug mode, which will put our browser and Only our browser into a special mode where we go back to the page and reload the page. If we have Google Tag Manager correctly installed, you should see a preview mode down here. And this will give us useful information on what is happening when the user interacts with our page. So for example, if I click on this image here, I will do this with the Command key press or the control key pressed in order for it to open up in a new tab. We see that our link click fired right here. And this needs to happen in order for us to know that our listener functionality actually works. So we know that our trigger is working correctly. We have here the link click, and with this link click, currently nothing is happening. And we can also click on the Buy Now button right here. And this is obviously desired click that we want to distinguish of clicks that are internal to our page and external. So we need a way to distinguish the fifth from the seventh click here. How would we do this? There is a new method to detect outbound links in Google Tag Manager. We need to create a variable for this. So let's go over to Google Tag Manager and click on variables. And here we're going to configure a new user defined variable. The variable type will be an auto event variable. And the variable type that we choose here is the element URL. And then we get this little compound Type menu down here where we can choose is this outbound. Now, there is one more setting called affiliated domains. So what this variable essentially does, it will detect whether the link that you have clicked is outside of the domain. It will look at the element URL. And if the element URL is different from the URL that Google Tag Manager is installed on, it will tell the variable Okay, this is an outbound link click. You can choose affiliated domains which are domains that you don't want to count as an external link click. So if you have any kind of subdomains or domains like paypal.com, where the user would naturally go to, but it's not really an external domain that you want to track, you can put them in here as a comma separated list. For us, this should be fine. We'll go ahead and give this all a name. Let's save this and see how this behaves. Let's refresh our preview and debug mode. Go back to our page, refresh that. And let's try this out again. I'm going to click on the internal link and then on the external link, and we see here we have our fifth and seventh click. Our fifth click doesn't have any tags firing right now, but we can look into the variables and especially in our autoevent variable that is outbound, and it says false. So this is actually an internal link click our tags shouldn't fire and we don't want to track this. But on the seventh link click we also have false. We see, I clicked on the image. The image is actually an internal link. But if I click on the Buy Now button, right here, so our ninth click, we see that the auto event variable turned true. So this is an actual click that leads our user away from the website. This is something we want to track. So we can now change our trigger over to only turn true when this variable is actually true. So let's go ahead in Google Tag Manager and turn our trigger into a specific trigger. So the link click will now be for outbound links, External links. And as this trigger fires on option we go with some link clicks, where the auto event variable is outbound equals true. That's really what this is all about. Now you can tick these option if you want to, but I will test them a bit month in depth so waiting for tags is a good option in order for the browser to have time to process the outgoing request to Google Analytics before he redirects the user on to the external website. And check validation is something you would need to experiment with, it pertains to the callback function that happens within the browser for the link. And if that is successful. For now, I will leave this turned off. Now since I click this first box right here, there's another menu that pops up, it says enable this trigger when all of these conditions are true. Now, this pertains to the listener functionality. Where do we want to listen to all of these clicks, I want to do this on all the pages. So I will go with the page URL matches regex dot star, which would match up to any URL that Google Tag Manager is installed on. So let's save this and we can really try it out because we don't have a tag that we would fire. So we would need to create a tag first. And the tags are the information that you sent over to your tool in the end. In our case, that would be Google Analytics. But you could also do this for Facebook ads or Google ads. So let's go ahead and give this tech a name. We want to build a Google Analytics tag, we're going to send an event and for external link clicks. As the tag configuration, we choose our Universal Analytics. And as a track time, this time we choose event. Now, we get all these different categories, you can fill them out as your heart's content. But be aware that this will show up in your reporting later on in analytics. So for us right now, I'm going to go with the category External links. Now, I also want to know what link was clicked. So I'm going to go ahead and choose an auto event variable. Unfortunately, I haven't activated them yet. Go with built in variables, and I'm going to choose the click text. And as the label I'm going to choose the URL that the user actually went to. So again, I'm going to choose a built in variable which is our Click URL variable, alright. As the non interaction hit, I will choose true. So it doesn't mess with my bounce rate. And I can choose where to send my Google this information, I have a Google settings variable already set up. If you don't have one set up, you can click on enable override settings and put your tracking ID in here in order to send it to the right account. Now we just need to choose the trigger. We already prepared that right here and save this. And now we get to the last part where we would test this on. So let's refresh our preview and debug mode. Go back to our page and try this all out. I'm going to click on an internal link first. We see nothing fires. Now, let's click on this Buy Now button. And we have the seventh link click and we see Google Analytics event external link clicks fired. Our tag fired and information should have been sent to Google Analytics. How can we verify? Let's go over to our tag assistant and look into the information that was sent over Google Alerts right here. One event was sent. This is our event that was sent. And we can see our category was External links. That's what we entered in our attack configurations. We have the action, which is the link text by now. And then the label the actual link that the user went to. Let's test a little bit more. Let's go can on, go to this blog page. Now, nothing should fire. Nothing fires right here. You're getting redirected on to our shop and our blog right here. And if I click on this wordpress.org link, what happens again, with the Command key pressed? We have a fifth link click, and our event external link clicks has fired. Again, let's look into our tag assistant. And we see Google Analytics one event fired. We have an external link click the action which would be the text of the link that was clicked wordpress.org and the label is the actual URL. So this seems to work as expected. And we have now tracked all the links that are external to our page on the whole website. Now let's verify one more time inside of Google Analytics. Inside of Google Analytics, we should see data come up in the real time reporting. So let's go here under events. And we see there was a link click right here. So a few seconds ago, if you go to events last 30 minutes, we see here our event category was external link clicks, and somebody clicked on the Buy Now button. Another one was, again, external link clicks, this time, somebody clicked on the link wordpress.org. Now this data will be recorded and later on, be available in your behavior reports under events right here. You should be able to see all the different external link clicks. Unfortunately, this takes a while to populate. So just for verification, we can see this in the real time reporting. All right, now that we have verify that everything is working. There's just one last step because this is actually not yet live on the website. And it's tracking user actual user information, you would need to submit a version. So it goes live on your website, give your version a name. So you recognize it. If you want to roll back later, then you publish this. And after a second, your version is now published, and it's live on the website. All right. So there you have it. This is how you can track external link clicks, and also your affiliate link clicks on your website with the help of Google Tag Manager. I hope this answers your question, Tom. And if you have a question, and you can leave it all the time in the comments down below, I read all of them and try to answer most of them if they actually make sense. And if you want to check out our MeasureMasters program, don't forget the link down below in the description. Now if you're new here, then you probably haven't subscribed yet. So I'll give you the chance right now over there. We bring you new videos every week. So you definitely should hit that subscribe button. Now, my name is Julian. see on the next one.
Info
Channel: MeasureSchool
Views: 26,473
Rating: 4.9207921 out of 5
Keywords: JavaScript, julianjuenemann, jjanalytics, tracking, measure, data, gtmtraining12, internet marketing, digital analytics, analytics, Marketing, Google Tag Manager, Track Outbound Link Clicks with Google Tag Manager, Track Outbound Link Clicks, Outbound Link Clicks, Link Clicks, google tag manager
Id: ZyKQzygB0Rc
Channel Id: undefined
Length: 13min 6sec (786 seconds)
Published: Wed Dec 11 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.