• Skip to main content
  • Skip to primary sidebar

How to Track Affiliate Link Clicks Via Google Tag Manager?

Reading Time: 4 mins. Posted on January 4, 2019 .

Boost your affiliate marketing efforts by tracking affiliate link clicks via Google tag manager. Sending link clicks data to Google analytics as events.

How to Track Affiliate Link Clicks Via Google Tag Manager?

Affiliate links are often masked as internal links by webmasters for natural linking. What I mean is, say Amazon India homepage link as an affiliate link is of the form:

https://amzn.to/2So3IDA

But, I can mask it as

https://biztips.co/go/amazon

or

https://biztips.co/r/amazon

or even

https://biztips.co/amazon

So to track such masked links, external link tracking tag won’t work. We have to use a separate trigger to track affiliate links via Google Tag Manager in Google Analytics.

So let’s begin.

Step 0: Pre-requisite

You should be aware of Google Tag Manager Lingo. Moreover understand what a trigger, tag, and the built-in variables available are.

The next is, you should have a Google Tag Manager for tracking site’s traffic in Google Analytics though it isn’t a must. We will still need to have the Google Analytics Property ID to send link clicks data to Google Analytics.

If you aren’t sure, refer to my article – How to Connect Google Analytics With Google Tag Manager first and then continue with this article.

Also, I assume some affiliate links are already masked and placed on a website or blog.

Step 1: Create Trigger

Affiliate link clicks triggers in google tag manager

  • Trigger name: Anything that you think will help you understand as the name of the trigger. I have it as “Affiliate Link Clicks” in the above image.
  • Trigger type: We want to have a trigger for link clicks on our website. So we choose  “Click – Just Links” type.
  • This Trigger fires on: “Some Link Clicks” and select “Click URL” > “contain” > “yourdomainname.com/affiliatelinkmask/”

If you are not masking affiliate links with prefix like /go or /r, one has to configure the trigger with a regex table. If you are using masked affiliate URLs with a prefix, you can move directly to step 2.

Step 1a: Create Regex Table Variable

Create a new User Defined Variable.

  • Variable Type: Regex Table
  • RegEx Table
    • Pattern: should be each affiliate url on your domain which is without a prefix
    • Output: should be true for all.
  • Set Default Value as false

Note: Under Advanced Settings, make sure the “Ignore Case” is check. “Full Matches Only” and ” Enable Capture Groups and Replace Functionality” both are unchecked.

You have to add each url you want to track for clicking in the RegEx table.

Tip: If you have many links, you can add them once and create the trigger. From now on, create new links as masked with a prefix like /go or /r.

Step 1b: Create Trigger

Now we will create the trigger as follows:

  • Trigger type: We want to have a trigger for link clicks on our website. So we choose  “Click – Just Links” type.
  • Trigger fires when: The variable created in step 1a “Is an Affiliate Link” “equals”  true.

So the trigger will fire when the variable we defined in the previous step has “true” as the value.

Step 2: Create a Tag

Affiliate link click tag in Google Tag Manager

  • Tag name: GA – Affiliate Link Clicks
  • Tag type: Google Analytics – Universal Analytics
  • Track type: Event (Select from the drop-down menu list)

Event Tracking Parameters

  • Category: Affiliate Link Clicks
  • Action: {{Page URL}}
  • Label: {{Click URL}}
  • Value: Leave blank
  • Non-Interaction hit: False
  • Google analytics settings: {{Google Analytics ID}}

The trigger for this tag will be how you have masked links with a prefix or without a prefix.

Masked link with prefix
Masked link without prefix

If you are using without prefix links till date and now want to use mask links with a prefix, create both the tags.

Track Your Tag in Google Analytics

Log in to your Google Analytics account and locate the Affiliate Link Clicks event under Behavior > Events > Overview.

Affiliate link click tracking in Google Tag Manager

Event action will list all the Page URLs which are getting the affiliate links clicks. We have mentioned it in the event tracking parameter called the Action.

 

Similarly, event label will list all affiliate URLs that are getting the clicks.

One can track the best performing affiliate programs. However, one can also find affiliate links which drive clicks but doesn’t generate enough revenue as well.

You are Here: Home / Tools / Google Tag Manager / How to Track Affiliate Link Clicks Via Google Tag Manager?

About Shabbir Bhimani

Blogging Since 2009. If I can leave my high paying C# job in an MNC in the midst of global financial crisis of 2008, anybody can do it. @BizTips I guide programmers and developers to Start and Grow an Online Business. Read more about me here.

May I help You With ...

Upwork Proposal
Finding Clients
Start a Store
Start a Blog
 

Or Help Yourself ..

Primary Sidebar

About Shabbir Bhimani

Blogging Since 2009. If I can leave my high paying C# job in an MNC in the midst of global financial crisis of 2008, anybody can do it. @BizTips I guide programmers and developers to Start and Grow an Online Business.

Get in touch with me on LinkedIn or read more about me here.

Let me Guide You to Start and Grow your Online Business

Download my
FREE eBook NOW
to win more clients.
And it is not an annoying pop-up either

Additional menu

  • Twitter
  • Linkedin

BizTips

Shabbir Bhimani: Start and Grow an Online Business

  • Freelancers Start Here
  • Start An eCommerce Store
  • Start A Blog
  • About
  • Archive
  • Disclaimer
  • Contact
  • Glossary

2009 - 2023 All my content & images are licensed as Creative Commons.

WebTurtles LLP. LLPIN: AAL-5288. Hosted with Linode.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT