Categories: Google Tag Manager

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

  • 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

  • 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.

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.

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.

Recent Posts

Absolute Beginners Guide to Google Ads

Free Google Ads Tutorial for an absolute beginner covering campaigns and their types, networks, keywords,…

2 years ago

How Freshers Can Make Money Programming in Java

Do you want to make money programming in Java? Here are 6 creative ways for…

3 years ago

Financial Freedom for Freelancers – 9 Smart Ways

9 smart ways for freelancers to achieve financial freedom. First, you have to believe it…

3 years ago

How To Become A Self-Taught Developer

With so many programming languages and resources available, it can be information overall to learn…

3 years ago

Wise Review – Best Exchange Rates For Indian Freelancers

Wise review from an Indian freelancers point of view to receive payments in India. How…

3 years ago

How to Tell a Client you Can’t Lower the Price?

There are 3 types of clients who want you to lower the price. How to…

3 years ago