Outbound Link Tracking
An outbound link click tells you when a user leaves your site to visit an external domain. For most sites, this means social media, affiliate links, partner sites, app store links, or competitor research. Knowing where your users go — and from which page — is worth having.
GA4 enhanced measurement (the free version)
Section titled “GA4 enhanced measurement (the free version)”GA4 automatically tracks click events for outbound links when enhanced measurement is enabled in your GA4 data stream settings. It fires when a user clicks any link pointing to a different hostname than the current page.
You’ll see these events in GA4 with:
event_name:clicklink_url: the destination URLlink_domain: the destination domainoutbound:true
The limitation: you can’t add custom parameters (like which marketing channel the link belongs to), you can’t exclude specific domains, and you can’t control the event name. If the default click event is good enough, use enhanced measurement and skip GTM entirely.
GTM approach: Link Click trigger with hostname filter
Section titled “GTM approach: Link Click trigger with hostname filter”For custom parameters, domain exclusions, or a different event name, use GTM.
-
Enable Link Click built-in variables. GTM Variables → Configure → enable: Click URL, Click Text, Click Element, Click Target.
-
Create a Link Click trigger:
- Trigger type: Click — Just Links
- This trigger fires on: Some Link Clicks
- Condition 1: Click URL — does not contain —
yourdomain.com - Condition 2: Click URL — starts with —
http(excludesmailto:,tel:,javascript:, and#anchorlinks) - Enable “Check Validation”: ON
- Enable “Wait for Tags”: ON
-
Create a GA4 Event tag with the outbound_click event.
GA4 - Event - Outbound Link Click
- Type
- Google Analytics: GA4 Event
- Trigger
- Click - Outbound Links
- Variables
-
Click URLClick TextPage URL
Set event parameters:
link_url→{{Click URL}}link_text→{{Click Text}}outbound→truepage_location→{{Page URL}}
Excluding specific domains
Section titled “Excluding specific domains”Some external links shouldn’t count as “outbound” — payment processors, authentication providers, CDN domains, or partner sites you own:
Add additional trigger conditions using “OR” logic isn’t possible directly, but you can use a Lookup Table or Regex Table to define a “is_excluded_domain” variable, then add a blocking condition:
Option 1: Multiple trigger conditions (simple case)
Add condition: Click URL — does not contain — trustedpartner.com
Add condition: Click URL — does not contain — payments.stripe.com
This works for a small list. For larger lists, use the Custom JavaScript approach.
Option 2: Custom JavaScript variable for domain exclusion
// Custom JS Variable: "CJS - Is Excluded Outbound Domain"function() { var url = {{Click URL}}; if (!url) return true; // Exclude if no URL
var excludedDomains = [ 'trustedpartner.com', 'stripe.com', 'paypal.com', 'accounts.google.com', 'auth0.com' ];
return excludedDomains.some(function(domain) { return url.indexOf(domain) !== -1; });}Then add a trigger condition: CJS - Is Excluded Outbound Domain equals false.
Tracking specific link categories
Section titled “Tracking specific link categories”If you want to categorize outbound links by type, use a Regex Table variable:
Create a variable named Regex Table - Outbound Link Type:
- Input Variable:
{{Click URL}} - Rows:
twitter\.com|x\.com→social_medialinkedin\.com→social_mediainstagram\.com|facebook\.com→social_mediaapps\.apple\.com|play\.google\.com→app_storegithub\.com→developer
- Default Value:
external
Add link_type → {{Regex Table - Outbound Link Type}} as an event parameter.
Tracking affiliate and referral links
Section titled “Tracking affiliate and referral links”For affiliate links specifically, you often want to track the destination domain and the referring page together:
// dataLayer approach for affiliate links with structured trackingdocument.querySelectorAll('a[data-affiliate]').forEach(function(link) { link.addEventListener('click', function() { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'affiliate_click', affiliate_partner: this.dataset.affiliate, affiliate_destination: this.href, link_text: this.textContent.trim(), page_location: window.location.href, content_block: this.closest('[data-block]') ? this.closest('[data-block]').dataset.block : 'unknown' }); });});Using data-affiliate attributes makes the intent explicit and removes guesswork from URL pattern matching.
Check Validation and Wait for Tags
Section titled “Check Validation and Wait for Tags”Both of these options matter for outbound links:
Check Validation — Runs GTM’s own validation check on the link. It verifies the link isn’t prevented from navigating (e.g., by e.preventDefault()). This prevents false tracking of links that don’t actually navigate.
Wait for Tags — Pauses the link click response for up to 2000ms while GTM fires its tags. Without this, the browser may navigate before GA4 receives the hit, especially on slow connections. Set the timeout to 500ms. Going higher than 500ms creates a noticeable delay for the user.
Common mistakes
Section titled “Common mistakes”Not excluding your own domain
Section titled “Not excluding your own domain”If you forget to add a condition excluding your own hostname, every internal link fires as “outbound.” Your GA4 data fills with your own domain as the top outbound destination.
A pattern that catches this: build a constant variable with your domain name (yoursite.com), then use it in the trigger condition: Click URL — does not contain — {{Const - Site Hostname}}.
Including mailto: and tel: links
Section titled “Including mailto: and tel: links”Links like mailto:info@example.com and tel:+12025551234 start with mailto: and tel:, not http. They will match a link click trigger but should typically be tracked separately. Add a condition: Click URL — starts with — http to exclude them from outbound tracking.
Forgetting to disable enhanced measurement after setting up GTM
Section titled “Forgetting to disable enhanced measurement after setting up GTM”If you configure GTM to send click events for outbound links AND keep GA4 enhanced measurement enabled, you’ll get double events. Either disable enhanced measurement’s “Outbound clicks” option, or change your GTM event name to something like outbound_click to differentiate.