Especially in affiliate marketing, where outbound link is essentially your product, tracking your links is important and gives you useful information. Even if you wouldn’t be an affiliate marketeer, setting up tracking for outbound links isn’t a bad idea.
Google Tag Manager
Google Tag Manager is a free tool from Google – What is tag manager. While you can obviously setup even tracking in Google Analytics, with Tag Manager you don’t have to add anything in your code. For larger websites, this allows the analytics team work in their own terms without the need of the development team. If you aren’t yet using Google Tag Manager, see the previous post on how to install Google Analytics via Google Tag Manager.
Setting up necessary variables
If you haven’t already added more variables to the default settings, chances are that you won’t have the necessary variables yet available to set up the tracking for the outbound links. If this is the case, add variables by going to variables -> configure and checking all the checkbox. While we aren’t needing all of them yet, you might as well just check all as it won’t really do any harm either to have all of them available.
At least make sure you have all the clicks enabled.
Create a new tag
Click to create a new tag and select the following settings.
Create a trigger
Now we need to create a trigger for the tag. Something that fires the tag we have created. Since we want our trigger to be fired on external links only, we have set a rule that fires the trigger only when the click target is blank.
Since WPTipster has cloaked affiliate links on the site, it uses the target blank to separate the outbound links from internal links. A cloaked link is basically an internal link that is redirected. Cloaking links is done for SEO purposes. Because of this, variables like pathname cannot be used as it would not track the most important thing WPTipster is interested in tracking, affiliate links. Check what plugin to use for link cloaking.
Preview and test that the tracking is working
Head back to overview page and click the preview button. This will allow you to preview the tags on your site. Sometimes new tracking may interfere with other scripts and cause parts of the code to brake. Because of this, it is always good to preview the new changes before submitting them live.
After you have entered the preview mode, go to your site where you want to set up the link tracking. If you click an outbound link, you should be able to see in the preview bar whether the tag was the triggered. If it was fired, test that the new tracking did not brake anything on your page and that inner links aren’t triggering the tag. If everything works as it should, you are ready to submit the new version.
Assuming everything went well in the preview mode, you are now ready to deploy the new tag. Click on submit and write a brief description on what has changed in the new version. If you are familiar with version control such as git, this phase should be quite self explanatory. After deploy, double check that everything is working. Now you are ready to track your outbound links. This data will be displayed in your Analytics account under Events.
Banner icon: Designed by Freepik