How-To Public

Tracking Outbound Links in Google Tag Manager using Google Analytics Events

Step 1: Enable Required Built-In Variables

Enable the built-in variables “Click URL” and “Click Text” (if not already enabled). GTM will need access to these variables to determine the target URL of the link that was clicked.

Step 2: Set-Up Trigger

Create a trigger called “outbound link click”. This trigger is intended to fire when a user clicks an outbound link.

A key question is: how do you determine if the link is an outbound link?

Recommended Trigger Configuration

Trigger Type: Click – Just Links
Wait for tags: Enabled

  • Max wait time: 2000ms (default)

Enable Trigger When: Page URL -> matches RegEx -> .* (i.e. enable on all pages)
Trigger Fires On: Some Link Clicks
Trigger Fire Conditions:

  • Click URL – matches RegEx (ignore case) – ^https?://
    This is a link to a URL, not an anchor link, a “mailto” link or a ‘fake’ link, such as an HTML A tag with no href attribute.
  • Click URL – does not match RegEx (ignore case) – ^https?://(www\.)?
    This is a link that does not point to a URL on the specified site.
  • Click URL – does not match RegEx (ignore case) – \.(pdf|xlsx?|docx?|txt|csv)$
    This is not a link to a URL file of one of these specific types.