Boost your affiliate marketing efforts by tracking affiliate link clicks via Google tag manager. Sending link clicks data to Google analytics as events.
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:
But, I can mask it as
or
or even
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.
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.