Mason Web Analytics

GTM: How to Determine if a Clicked Link is an Internal or Outbound Link

When setting-up trigger firing criteria:

Option 1: is the given domain name in the click URL?

Click URL -> contains -> masonanalytics.gmu.edu

Option 2: is the given domain name in the click URL using regular expressions?

Click URL -> matches RegEx (ignore case) – ^https?://(www\.)?masonanalytics.gmu.edu

Option 3: using custom javascript variable

Credit to https://www.simoahava.com/gtm-tips/10-useful-custom-javascript-tricks/#4

IsInternalLink – Function to determine whether the GTM Page Hostname (built-in variable) occurs within the Click URL . If it does, return true; otherwise return false.

function() {
// Does the page hostname occurs within the click URL . If it does, return true; otherwise return false.
return {{Click URL}}.indexOf({{Page Hostname}}) > -1;
}

Option 4: using a more awesome custom javascript variable

This option would use a regular expression to be more specific about how the Page Hostname can occur in the Click URL.