Cloud Confusing

Explaining hosting, AWS, Wordpress, static sites, and all manner of cloud solutions.

If you want to track clicks out of your site but you don’t own the page that is being linked to, it might not be immediately obvious how you can learn about your outgoing clicks. Some partners offer a conversion mechanism (a conversion pixel, callback, etc.) but many don’t. Plus not every click results in a conversion so keeping track of the people who are clicking out of your site can make a lot of sense. But how do you do it?

Don’t worry: tracking affiliate links clicks (or any other click on your site) is super easy and free.

Meta Note: This is a bit of a diversion from the site’s normal work with Amazon Web Services, but I do a lot of work with Google Marketing Platform (aka Google 360 tools), mainly Google Analytics, so this seemed like a worthwhile topic.

For this article we’ll setting up click tracking with GTM (Google Tag Manager) and GA (Google Analytics). This is a fairly standard stack, but it’s far from the only way to track link activity. You could also do it with a RegEx table, with a link shortener like Bitly, or any number of WordPress plugins.

The nice thing about this way is that it’s super easy, you are probably already already using Google Analytics for your web analytics, and it’s very scalable. GTM has an incredible number of features, so once this it’s setup there is lots more you can do.

If you don’t know what GTM is, it’s a tag manager. It places a container on your website that you can put stuff in. This way next time you want to add third-party tags to your site, you don’t need to do a release, you can just add them into GTM and update it. GTM has a number of other things it can do, like listen for links, track scroll depth, set user timing events, etc. We are going to take advantage of one of those site benefits now.

How GTM Click Tracking Works

Here’s the simple version of what’s happening: You put a GTM tag on your site, we tell the tag to listen for click to any clicks that follow a certain pattern, like “amzn.to” or “amazon.com” or “shareasale.com.” When GTM notices once of those links get clicked it fires an event that gets sent to and stored in Google Analytics. An event contains a category, and action, and a label, which you will define.

Events are a data type in GA that you can go back and check at any time, just like a pageview. In fact, a pageview hit is basically just an event. Using your set category, action, and label can store things like where the click happened, what product was clicked, etc.

If you want to see events in GA, you simply need need to navigate to Behavior > Events.

How to Setup GTM To Track Clicks

First of all, the Tag.

To track links with you’ll need to setup a new account and tag in Google Tag Manager. I’m guessing you don’t have either those yet. As you run through your new Tag setup you’ll want to choose these settings:

  • Tag Configuration: Google Analytics Universal Tag
  • Track Type: Event
  • Category: This is where you name the Event category. Something like “Affiliate Click” maybe.
  • Action: {{Page Path}}
    This will return the URL of the page where the click happened.
  • Label: {{Click URL}}
    This will return the URL that was clicked. If you don’t see this as an option you can enable it in the “Built-Ins” menu at the top right.
  • Value:
    You can populate this or not. I left mine blank.
  • Google Analytics Setting: The easiest thing to do here is to pick override and insert your Google Analytics Tracking ID. It’s the one that starts with “UA-“
  • Ignore the rest until you get to “Trigger.”
  • If you need to tinker, I’d recommend adding a custom dimension. This will allow you to sort through pageview hits and/or GA custom reports and find pages that had affiliate clicks. I simply set Custom Dimension 1 to be “True” if a an event was logged.

Now, the Trigger. This is what tells that Tag to fire your event.

Now go to the Triggers tab and make a new Trigger.

  • Trigger Type: “Just Links” in the Click menu
  • Skip “Wait for Tags” and “Check Validation”.
    These will help your data accuracy as the expense of page performance. They aren’t that big of a deal for affiliate tracking (in my opinion).
  • This Trigger Fires On: Pick “Some Link Clicks”
    Now is your chance to pick which links get tracked. For example, to record Amazon affiliate clicks pick:

    • “Click URL” “contains” “amzn.to”
  • Save everything, now go back to your tag and associate it with the Trigger you just created.

How to Verify Your Link Tracking Works

With all that done, you just need to save and publish your container. Make sure the GTM tags are on your site — this is as easy as throwing them in the head and body of your template — and you are set.

How will you know your events are firing and your links are being tracked? After publishing, find the “Preview Mode,” then navigate to your site in another tab. When you get to a page with your link click it and you will see the event fire. You can also look for the same happening in your network activity. You’ll see something that looks like this:

Executing Google Analytics commands:
VM46 analytics_debug.js:10 Running command: ga(“gtm4.send”, {hitType: “event”, eventCategory: “Affiliate Click”, eventAction: “example.com/directory/index.html”, eventLabel: “https://amzn.to/123123123”, eventValue: undefined})

That’s using GA Debugger console view, but you can see it in your network activity manually as well.

You could also go into GA > Behavior > All Pages. Now pick “Secondary Dimension” from the dropdown and search for “Custom Dimension.” If you setup a CD it’ll be there. Just be warned: where events will show up immediately, custom dimensions might not populate for a day or two!

Or if you want to use Easy Mode, you can just go int Google Analytics, then into Real-Time, and look for events as they take place.

August 10th, 2018

Posted In: Web Development

Tags: , ,


© Cloudconfusing.com 2022 | Privacy Policy | About | UTM Creator | CVE Reporting