Affiliate marketing is a great way to generate income online. Currently, I make about $200/month using affiliates!
To promote external links effectively, you need to make sure that your marketing is working and generating traffic through the affiliate links.
Tracking clicks & views through Google Tag Manager and Google Analytics 4 allows you to know “is your affiliate working” on the click your current marketing strategy and provides you with the data needed to inform future action taken on said strategy.
Let’s go through how to track affiliate and outbound traffic by monitoring link clicks. We will measure traffic and engagement with these links, visualize and display this data clearly and concisely, and provide a logical path to action.
Set Up βClicksβ in Google Tag Manager
The first step in displaying your affiliate links is gathering the data. Google Tag Manager allows you to track all clicks on your website and differentiate between on-site and outbound clicks.
In case you have randomly stumbled upon this article and donβt know whatβs going on right now.
No worries! We have you covered! Before you continue reading, check out this incredible video by our very own Stockton Fisher thatβll help you get started.
Back to the main event. Letβs hop right into GTM!
In your GTM container, we are going to create a new tag.
If your screen looks like this, youβre on the right track. Click on βChoose a tag type to begin setupβ¦β
You will be prompted with a list of tag types. Select βGoogle Analytics: GA4 Event.β
For the basic set-up of this tag, youβll need to select a configuration tag and name the event.
Select your containerβs config tag, and name the event βclickβ.
Before we move on to the next step, make sure to click Save.
A prompt will pop up and ask you to add a trigger. We will add one eventually, but for now, just save the tag.
GA4 Click Varriables
Next, we will need to set up several parameters that will allow us to gather and store detailed information about what exactly is being clicked on our page.
To set up these parameters, we need to create four different variables. Three out of four of these variables are built into the Tag Manager System. They must be manually turned on.
Under the variable tab, click βConfigureβ for Built-in Variables.
In general, itβs helpful to just turn on all of the built-in variables, but for the purposes of this article, we only need to toggle all the Click variables on.
For the first three variables, this is all that you need to do to complete their set-up. The fourth and final variable is a bit more complicated.
If you scroll further down the variables page, you will see a section titled βUser Defined Variables.β At the top right corner, click the button that says βNew.β Title your new variable βClick – Outboundβ or something similar.
Auto-Event Variable
Next, we need to select our variable type. Open the menu and scroll down to the section titled βPage Elements,β and select βAuto-Event Variable.β
Open the menu and select βElement URL.β Selecting this option will create a new field called βComponent Type.β Open the menu and select βIs Outbound.β Your variable should look like this.
Now we are going to head bag to our Click tag and finish setting it up.
Click Variables – Implemented
Under Tag Configuration, select βEvent Parameters.β This is where we will make use of the variables we just created. Add five rows so we can input the five variables. For the five parameter names, you will want to use outbound, link_url, link_classes, link_domain, and link_id. Under βValue,β click on the icon that looks like a lego brick with a plus sign on it.
Your tag set-up should look like the above.
Next, we need to create the trigger for our Clicks Tag. Click the section on the bottom titled βTriggering.β
Next, we will need to βChoose a Trigger.β Click on the plus in the upper right-hand corner. Name your trigger βAll Link Clicks.β
Next, click on βTrigger Configurationβ and select βJust Linksβ under the Click section.
Stick with the default setting for this trigger. You do not need to alter the specifics.
Save your trigger and then your tag.Β
Congratulations! You have set up your Clicks Tag! ππππ
Now that this tag is set up, it will track all the link clicks on your website, will store the URL, class, and ID of that link, and it will differentiate between on-site and outbound links!
Tag Manager is a complicated platform, and even the best of us make mistakes every now and then. It is good practice to preview and test your tags before submitting them. This allows you to make sure your tags are running correctly without skewing any data.
Build A Dashboard That'll Get People Talking!
Still not sure?
Previewing βClicksβ Tag
In the upper right corner of your screen, there is a βPreviewβ Button. Click it!
Enter the URL of your website and click Connect.
Navigate through your site and click on a button or link. Then head back to Tag Assistant, look for βLink Clickβ in the sidebar, and select it.
Your GA4 – Clicks tag should have fired with this event.
To check the parameters we added. Click on the tag to open it up.
As you can see, we are now tracking if the link was on-site or outbound (this link was not outbound) and the rest of the values that we set. Some of these values may be blank, such as link_id above. That does not necessarily mean something is wrong; it may just be that there is no value set for that dimension on your site.
In order for us to visualize the information we have just collected, we need to give GA4 the tools to understand our custom parameters. Letβs jump right into that!
Google Analytics 4 Set Up
In your Google Analytics 4 Account, head to the section titled βConfigureβ and select Custom Definitions.
These are your 4 custom dimensions
In the top right corner, click βCreate Custom Dimensions.β You will need to create four custom dimensions β one for each parameter we set. Below are images showing you exactly how to set up each dimension. Take a look! π
And just like that, we are done in GA4. Letβs head over to Looker Studio to visualize some of this information!
NOTE: GA4 takes around 24 hours to start showing newly added data. So, you will need to wait about a day to visualize your affiliate link clicks. If they arenβt showing up before 24 hours have passed, donβt worry, that doesnβt necessarily mean anything is broken.
Looker Studio Reporting
We can create clear paths to action through data visualization and efficiently and effectively improve our marketing strategies. Looker Studio is an incredible tool to do just that.
For the purpose of improving affiliate marketing, we need to create a table that will show us which links on our sites are getting the most and least traffic.
To begin, open Looker Studio and create a blank report.
Once the report has been created, we need to connect our data source. At the top of the page, in the toolbar, select add data.
A menu with several connector options will pop up, but for now, we only need to connect to Google Analytics. This should be the first option in the menu. Click it and select your container.
Once we have connected our data source, we can begin visualizing our data! ππππ The visualization for this particular data set is best formatted in a table. In the toolbar, click add a chart and select the table tool.
The dimensions we will need to begin are Event Name, Outbound Link Clicks, and Link URL. We will only need to use one metric: Event Count. You can add these to the chart either by dragging them from the menu on the right-hand side of the page directly onto your table or by placing them in their respective categories under βSetup.β
With these dimensions and metrics and this configuration, the table will display all GA4 events and list both on-site, and outbound link clicks.
We only want to see outbound click events, so we need to add filters to our table to eliminate the excess data.
Scroll down to the bottom of the set-up menu and select βAdd a Filter.β We will add an Event Name filter and an Outbound Link Clicks filter. See below for the exact setup.
Once you have added these filters, you will no longer need the dimensions for Event Name or Outbound Link Clicks. This will leave you with a chart similar to the one below. This chart shows how many times each outbound link on your website has been clicked.
If you are seeking to track one specific affiliate link, you will need to add a filter that includes its specific Link URL. I suggest you remove the βhttps://β and select contains rather than is equal to.
And Ta-da! You have displayed Affiliate Link clicks for all pages of your website using GTM, GA4, and GDS. Thatβs quite the feat! Youβre too good at this! π
You are more than welcome to stop here, but why not add some pizzazz by utilizing that style tab? Though remember, sometimes less is more. I like the color green so, behold, a green table. π
You have creative control! Go on, have some fun. You deserve it!