Sunday, 24 May 2020

Tracking clicks external links across a website (exit tracking)

External links are links to other websites from your website.

Tracking clicks on all external links is known as exit tracking or outbound tracking.

Through exit tracking, you can measure the volume of traffic your website is sending out, to other websites. This type of tracking is especially useful if you run an affiliate website.

Follow the steps below to track clicks on all external links on your website via Google Tag Manager:

Step-1: Create a new trigger with following similar configuration:
Trigger Name: Check for clicks on External links
Trigger Type: Click – Just Links 
Check Validation 
1. Enable this trigger when all of these conditions are true: Page URL matches Regex .*2. This trigger fires on: Some Link Clicks3. Fire this trigger when an Event occurs and all of these conditions are true: Click URL does not contain <<yourdomain.com>>
Note(1): replace ‘yourdomain.com’ by your website name.
Note(2): ‘Click URL’ is a built-in variable in GTM, which returns the ‘URL’ of the clicked link.
Note(3): The ‘Fire this trigger’ condition makes sure, that this trigger does not fire for clicks on the links, which are internal i.e. the links that contain your domain name.

Step-2: Create a new tag with the following configuration which send clicks on external links to Google Analytics:
Tag Name: Send Clicks on external links to Google Analytics
Tag Type: Universal Analytics
Track Type: Event
Category: Traffic to Other Websites
Action: {{Click URL}}
Label: {{Page Path}}
Non-Interaction Hit: True
Firing Triggers: Check for clicks on External links
Note(1): {{Click URL}} is a built-in variable in GTM which returns the URL of the link clicked. You can select this variable from the dropdown menu.
Note(2): {{Page Path}} is a built-in variable in GTM which returns the URL of a web page.

Step-3: Preview your container to make sure that the new tag is firing.

Step-4: If everything is working as intended then publish the new version of your container.

Scroll Tracking via Scroll Depth Trigger in Google Tag Manager

Step 1: Enable the Scrolling Data Layer Variables

In GTM > Your Workspace > Variables > Configure new “Built-In Variable” > Check the three boxes below:


These Data Layer variables are defined as:

  • Scroll Depth Threshold: this is the depth of the user scroll (e.g. 25%, 50%, etc).
  • Scroll Depth Units: this is the % or pixel setting of the scroll.
  • Scroll Direction: this is either vertical or horizontal.

Step 2: Enable the Scroll Depth Trigger

In this step, you’ll enable the built in GTM scroll depth trigger that will help push the Google Analytics custom event data that you’ll configure in step 3 below.

In GTM > Your Workspace > Triggers > Add New Trigger > Select the “Scroll Depth” Trigger Type below:


This is where where the setup becomes subjective to your unique needs:
  • Do you want to measure in percentage or pixels? (I use %)
  • Based on your % or pixel selection, what thresholds do you want to set up as trigger points (e.g. the point in a user’s scroll on your site where you’d like this trigger to fire).
  • Do you want vertical or horizontal scroll depth tracking? (majority of cases this will be vertical)
  • What pages do you want this scroll depth trigger to fire on? (I fire on all*)
*In some cases you may want to limit this to content rich/blog pages only, however having this data on eCommerce home, category, or product pages can unlock potential insights like:
  • Are paid search visitors engaging with my category pages and viewing a good amount of products before exiting?
  • Are users of my product pages scrolling down to view my user generated content that I’m investing a lot of $ into?
  • How does user engagement differ between mobile and desktop?
Here are my settings:


Step 3: Setup your Custom Event Tag

Now you have your variables enabled and trigger created so the final step is pushing this new data into Google Analytics!

In GTM > Your Workspace > Tags > Add New Tag > Select a new Universal Analytics tag where we’ll set up the following details:

  • Track Type: Event
  • Category: I’m using Engagement here to help group similar Event Actions across other tags
  • Action: I’ve selected one of the new GTM Scrolling dataLayer variables {{  Scroll Depth Threshold  }} – which contains the numeric value of % values configured in step 2 above.
  • Label: I’ve selected {{  Page URL  } which is another native variable in GTM that records the page URL that a user is triggering this tag.
  • Non-Interaction Hit: I choose to set this to “True” which means these custom event triggers will not count towards my bounce rate measurement.
Step 4: Confirm this tag is working!

Configure your Preview mode within GTM, then visit your site, and begin scrolling :).