March 28, 2020
How to Track Affiliate Link Clicks with Google Analytics and Tag Manager

How to Track Affiliate Link Clicks with Google Analytics and Tag Manager


– In this video, we’re gonna learn how you can track your
affiliate links on your website with the help of Google Tag
Manager and Google Analytics. Hi there, and welcome to another
video of measureschool.com where we teach you the data
driven way of digital marketing. My name is Julian. So, today we’re gonna
talk about affiliate links and how we can track those with Google Analytics
and Google Tag Manager. It’s actually pretty easy, I have an example here on this website. I have affiliate product, that
when you click on this button will lead you to amazon.com and we hopefully get
our affiliate commission once the user buys this product. Now, we won’t be able to track
the actual Buy on Amazon.com. In this case DE, but we will be able to track whether the user click this button. In any interaction that the
user actually takes on our page can be tracked with Google Tag
Manager and Google Analytics and for an affiliate site, this click would be the ultimate goal to actually track within Google Analytics. So, how would we go about this? Now, the first thing that we would do is actually look at the link
that this click points to. We can see it here in
the bottom left corner or if you want at little bit more visual, I’ll go here on the Inspect Element and, oh, where can we see it? Set this again. Right here we see the “a
href” and this is the link that this button points to and the user will be directed to. Now, there’s actually a short link so when you actually click it, it expands and shows the full URL but this can be ignored for now. We just need to be able to
recognize the uniqueness about this link because if you have
other affiliate products, we don’t wanna go through
and track them individually, we actually wanna install one tracking with Google Tag Manager that tracks all of our affiliate links. And if you ever worked with
Amazon affiliate links before, you know that this
amzn.to is pretty unique to this Amazon affiliate links, at least the short links
could also be amazon.com and you would have
these longer links here, but the amzn.to should do for now. We just gonna remember this
and install our tracking with Google Tag Manager. So, let’s head over to Google Tag Manager and we’ll start out by
generating a click trigger. So, let’s go over to Triggers
and click on New here and this will be our
Click Trigger for now. We’re just gonna name this pretty generic because we’re gonna change it later. And as the Event, we’re
gonna choose to Click and specifically, in the second step you
wanna look at Just Links because this is actually link
as we seen in the HTML marker. So, let’s click on Just Links and let’s keep these
options checked off for now, we’re gonna get back to them later. Let’s continue and let’s
click on All Links for now and create this trigger. So far, pretty easy. And we’re gonna do now is going to our preview and debug mode which we can do under the Publish button which will put our browser
and only our browser into a special mode that will deploy our tags and our triggers only on our browser. So, we can head back to our
page and reload our page here. And we see, we get a little
preview and debug console that gives us more information
about what is being deployed by Google Tag Manager. For now, I have a Google
Analytics page view tag that I’m ready to deploy. Now, we wanna see what happens when I click on this Buy product link and I will do this with
the command key press, so it actually opens up in a new tab and keeps this site loaded. So, we do this with
the command key pressed and I clicked and we see a event down here called the gtmlinkClick. Once we click on this gtmlinkClick, you see that nothing fired on this event but we know that this interaction is actually now being picked
up by Google Tag Manager and we can further work with it. So, if this doesn’t get picked up in your Google Tag Manager account, you might need to change up your HTML console custom listener. Next thing we can do is
actually check the variables. Now, the variables don’t
tell us too much right now because we haven’t yet activated
our Auto Event Variables, we would need to do that
in our Variables here and we see here, Built-in Variables and here’s also a special click variable and the one that I’m interested in is the actual Click Target so the URL that the user is pointed to but we can also activate
all the other ones so we get a full information here. So, let’s refresh our preview
and debug mode, very important and go back to our page, let’s close these and reload our page. Alright, and I’m gonna click
the Buy product button again with the command key pressed. We get the event again
and under Variables, I now have all the variables
I have defined beforehand and we see what gets filled
and may not get filled. In our case, the interesting part, I thought was the Click Target
but this doesn’t get filled because of the markup of the page, and what gets filled
is the actual Click URL that features our URL with the amzn.to which is pretty unique
to our affiliate links, and therefore, we wanna use this Click URL to filter down our
trigger and later our tag to only fire when a user
clicks on this amzn.to link. Now, this might be different
for your affiliate links, maybe Click ID gets filled
and you just need to make sure that you have a unique point
that you can base your filter of your trigger in order to target the right links on your page. So, we’ll go with this amzn.to, just gonna copy this head back over to Google Tag Manager and go back to our Triggers and let’s first of all, click in here and rename our trigger, this will fire on a click event and specific to amzn.to links also called affiliate links. Alright, now in the second option, if you want to, you can
choose Wait for Links and Check Validation. This will actually listen back to the side and see if the user has
actually clicked this link and he will successfully redirected on. This can be particularly interesting because if the user list the site, which he doesn’t now in our case, Google Tag Manager will
delay the redirecting for two seconds and be
able to fire our event tag that we want to deploy
via Google Tag Manager. So, this is quite useful for out case. So, let’s continue here, and then, there’s a
new option that pops up which will ask us, when do we actually want
to listen for this clicks, and in our case, we want to
listen for it on all pages so we can just go ahead and
click on Page URL, contains then our domain, in
our case, demoshop.com. So then listen to all the pages out there that are tracked. Let’s continue and here we
will now use our knowledge from our Variables to
filter down our trigger. So, we go with some clicks here and choose the right variable that we just saw in the
preview and debug mode, in our case, that would be click URL which should contain amzn.to. Now, you can be all fancy with this and use RegEx as well. We have a tutorial on this as
well that you can check out but in our case, we just had Amazon links on our different products and
they should contain amzn.to. So, this is when I want to Fire On Event into Google Analytics and
track our affiliate click. Let’s save this trigger and let’s connect it to our tag. For that we go over to
tag and click on New, you will notice, I have
already a page with tag. This is the normal
Google Analytics tracking that normal sites have installed and we’ll add another GA tracking, this time, it will be Event Tracking and this is specific
to our Affiliate Links. As a product, we go of
course with Google Analytics, we have Universal Analytics
running on our page and the tracking ID is
already saved in a variable called GoogleAnalyticsid. If you wanna look at it up how
to store in such a variable, then check out our video
on Google Analytics on constant variables. And as a track type, we’ll choose Event. Now, Events has different properties here that we need to fill
especially Category and Action and our Category should
always be Affiliate Links, and then the action could
be click for example but we wanna get more
relevant information actually about what link was actually clicked. So, in our case, I want to know the actual
link that was clicked so I will go with Click URL and this will simply take our URL and input it here as an action and then, we’ll go with label and this is actually one bucket beneath the Action and the Category so you can use that also to
fill in useful information although it’s optional. In our case, I want to
know on which web page did this click actually happen. So, I will go with Page Path. Now, for the Configuration
is the Non-Interaction Hit which is important if you don’t wanna
affect your bounce rate, set it to True. Now, in our case, the
interactions on the page which I want to count
towards the bounce rate so I keep this on fault. Let’s continue here and connect this all to our trigger in the first step which
we already prepared and just choose this, save and create this tag. Let’s Refresh our preview and debug mode and go back to our page. Let’s refresh this as well. Close this tab. And I click on this Buy
product button again with the command key pressed. And you see that we have our new event, the gtmlinkClick, once we click on it, we see which tags have
fired upon this link click and we can even look at this link click and see why this trigger has turned true because our Click URL had amzn.to in it, and what information was our Event Action, Category and Label filled with, and these were dynamically
filled with the URL that this link points to what the user has left to. The category which we
have to find beforehand which was Affiliate Links
and the Event Label. Now, to check this all, we can
also go into Google Analytics into the actual Real Time Reporting and on the Events, we should
see our events coming in as somebody clicks on
such and affiliate link. So, we see up here our
Affiliate Links, Event Action and the Event Label. So, this works as expected
and is now ready for testing so we could also do a negative test and click on another link that isn’t an affiliate link, so for example, down here
we have an email link or on the home page, I think, demo links here, there’s
an Outbound Link Click, this is an outbound link. I’ll click this again with
the command key pressed, you get a gtmlinkClick, but this time, the event didn’t fire and nothing was transferred
to Google Tag Manager because of how we set up the filter. So, this works as expected and is now ready for deployment. So, we can go into our Google Tag Manager, actually turn off our
preview and debug mode. And then publish this as
a version to all our users that visits our page. So, we’ll not only be
deployed on our browser but now on all the browsers. You can again do a little test here, go back to our affiliate product and click on the Buy product button, we have redirected on and now
in our real time reporting, we should see a new event with
our affiliate link clicked. Now, you can also see the data later in the Behavior and Event Report where you then have access
to all the affiliate links that were pressed on your website. Now, this will take a while to populate, so you can check back after a day and we’ll probably have a lot of different affiliate links clicked depending on how many users
you have on your website who clicked on affiliate links, and of course, if these
clicks are the main goal of your website, I would recommend to also set this up as a goal for your website. So, you can go here to New Goal, choose a custom variation here, should be our Affiliate Click, choose the ID slot and as
type, you would choose Event, and simply the Category would need to be whatever we filled in as a
Category, Affiliate Links. And we can save that and we would also have
this saved on our reports as a goal and we could, for example, look how many people from a given source have clicked on our affiliate links. So, that’s already it with this week’s video
of measureschool.com. If you liked this video,
please give us a thumbs up and subscribe to our channel, and if you wanna check out more events that you can check with the
help of Google Tag Manager, then head over to our
event tracking course under measureschool.com/eventracking. We will show you how to
track more interactions that the user can take on your website with the help of Google Tag Manager. My name is Julian, ’til next time. (upbeat music)

51 thoughts on “How to Track Affiliate Link Clicks with Google Analytics and Tag Manager

  1. is there a tutorial how to make a report with google analytics with what we did in this lesson
    for example a report that show how many clicks i had during a period of time ?

  2. Awesome videos man. I tried this one for an Amazon affiliate link, except the link I have is in an iframe. Not sure if I can take it out of the iframe, or if theres a way to track while in an iframe?

  3. Hey,

    Thank you for this awesome video. Everything works fine in my case, apart from the fact that no event occurs in my Google Analytics Dashboard. So the event is recognized, but no data is transferred to Analytics. Any suggestions?
    Thanks in advance for your help!

    Viele Grüße,

    Vincent

  4. hi i have applied this function on my website but next day i didn;t find previous record in google analytic it is possible to see my click data after next day ?

  5. Thank you so much for this tutorial! Great work and smoothly explained. Exactly what I was looking for 🙂 Keep going with that greak work!

  6. Hello Julian

    When I reproduce your link opening at 3:56 (with "open on new tab", I've got a pc) the tag doesn't appears.
    But when I click directly on the link the tag appears shortly before my page changes.

    Do you see what it might be ? I am unable to track click-event on my G-A.

    Thanks and regards
    Edouard

  7. Could you explain how you set up your tag for this? Because your tag is already created, right? You used Global Analytics? What were the parameters? My tag manager is labeled "Workspace" not "Container" I think this was part of an update. Can you explain how to create the tag for tracking clicks?

  8. Great tutorial. But why did you put {{Page Path}} as an event label? Usually the page path is part of the event data no? So you can always slice and dice data in GA to see where the event has happened?

  9. Do you have a mouse shortcut to close a tab?

    I saw you didn't click the X button but you closed your tabs just with your mouse click. wtf? 😀

  10. Julian. I have a question…. how can I send over the Tag Manager Trigger Name over to Google Analytics? I don't want to create a new tag for each product and each product only has ASIN number I made one tag for Amazon affiliate clicks, and I am making triggers for each image clicked on (for when they don't got to the actual product page, but click a picture and go straight to amazon)… but no label goes with it and I don't want to look it up each time I view my analytics info. So I tried to make a lable in GA, but can't figure it out. Or can I assign a user defined variable in TM and then assign that to a specific trigger? I hope you understand what I'm trying to do here. I mean I could write my own code in php and create my own report, but I want it all in GA. I hope you have an answer… thank you in advance.

  11. When i check that last step, it shows all pageviews i guess. I see numbers which are the same as with conversion set to all???

  12. I don't see Clicks anymore under the Variables sections – I guess GTM has updated since this video. What would I do now in this case? Thanks!

  13. HI Julian, great video and explaining of the concept, i would like to ask you.. how can i track my affiliate link to a level of which ad on adwords, made triggered the affiliate link on my website and eventually made the purchase on amazon?
    thanks

  14. Julian! Thank you so much for the excellent video. I've learned a lot!
    I have a question, and I hope you could help me out or maybe point the video I should watch.
    So, We are planning to use Native Advertising on our website.
    The ad will open as a pop-up, not in the separate tab.
    If we want to promote some event and for example redirect users to another website where they can buy tickets, how can we track if the user purchased the tickets or sign up etc.?
    I would appreciate your help!

  15. Thank you for this tutorial. Is there a way, we can attribute such events to the channel/source of traffic. For example, if we have traffic from paid search and if the button click triggers an event, will we be able to attribute that event to paid search or organic or social. Might be a stupid question. Any explanation or help could be of great help. Awaiting your response. Thanks,

  16. Just FYI I was selected to be a beta tester for Amazon's OneTag based Content Insights click/sale tracking however I'm not confident about any effects or problems it may have. So I appreciate learning how to do this and take advantage of existing Analytics features rather than having to add even more JS overhead etc.

  17. Hey guys i recently signed up for this mobile app & offer affiliate program. And here are a few questions

    – what is a global postback link & how to make it & also where to make it.
    – what resources I need to do this?

    I hope you fellow affiliates have some ideas as for strategy- I am planning to run mobile display ads if you have any more ideas do tell me

  18. Hey, there is a issues while checking in analytics real time events
    I have used a plugin which has the link of amazon.com while on product title I have used amzn.to. So I have added both in Click Url contains amzn.to and amazon.com but in event it is only tracking amazon.com links not amzn.to. Please solve.

  19. @4:19 – I can't see the click action =/
    And I don't really get how to fix this. How can I "Change my HTML" or "Install an custom listener"? Just something to put into google search would help me – those fix hints are just a little bit to random. Please help!

  20. Great content Julian! Thank you so much for sharing! =)
    For me, the two options @6:41 "Wait for Tags" and "Check Validation" didn't work out: I could see in the trigger that the third check – a strange RegEx with numbers like an ID – failed. Don't know exactly what this third check ("_triggers matches RegEx", see @10:56) does, but it failed =/
    Removing the two options in the trigger made it work.

  21. followed all the steps but when i got to the tag and finished making it and went back to try to button again, the trigger is not firing.

  22. No event occurs in my Google Analytics Dashboard. So the event is recognized, but no data is transferred to Analytics. Any suggestions? Plz help

  23. Julian! You need to show people how to remarketing to people who clicked on an affiliate link. They must do GTM Outbound Click > Set up GA goal > Create remarketing audience within GA.

  24. so I tried this and it worked perfectly for 5 of the 6 websites I manage, but on the sixth checking "Check Validation" broke the trigger. Anyone have any idea why that might be the case? I still managed to do it, but I had to tick off "Check Validation." Is this an issue with how the website is set up? Maybe a problem with the cookies? Idk. Any suggestions?

  25. Hi julian, in indonesia a lot of affiliate market, what the best practice to do that ? example at the website have 3 button for 3 different marketplace. (amazon, ebay, alibaba) thanks Julian 🙂

  26. So there is no way to filter out actual buyers righ? Is there any way to stop retargeting for those who already purchased our affiliate offers?

  27. Will GTM tag get blocked from deploying in some browsers leading to lost commission? If so is there a way to track blocked tags? Awesome video by the way, thanks !!!

Leave a Reply

Your email address will not be published. Required fields are marked *