Sub topic 5
Outbound clicks and how GA4 decides a link is outbound
This chapter assumes you have a GA4 property with a web data stream and the Google tag installed (gtag.js or Google Tag Manager). It also assumes you know the GA4 event and parameter model and can find enhanced measurement in the Admin interface. The code examples use basic HTML and JavaScript.
What the outbound click event records
When the Outbound clicks setting is on, GA4 records a click event each time a visitor clicks a link that leads away from your site. The event is added automatically by the Google tag. You write no code and create no trigger.
The event is named click. This name is general, but GA4 sends the event only for outbound links. Clicks on links within your own domain do not produce it. Because of this, a click event in your reports always means "left the site". Other kinds of clicks need custom events.
The event carries these parameters:
| Parameter | What it contains |
|---|---|
| `link_classes` | The value of the link's `class` attribute |
| `link_domain` | The hostname of the destination, such as `partner.example.org` |
| `link_id` | The value of the link's `id` attribute |
| `link_url` | The full destination URL |
| `outbound` | The value `true` |
The outbound parameter is the marker that tells you the click left the site. link_url and link_domain are the most useful for analysis, because they tell you where visitors go.
How GA4 decides a link is outbound
The Google tag compares the destination of the clicked link with the domain of the page the visitor is on. A link counts as outbound when its domain differs from the current page's domain.
Several details affect this decision:
- Domain comparison. The tag looks at the hostname in the link's
href. A link tohttps://other-site.com/pageonwww.example.comis outbound. - Subdomains. Treatment of subdomains depends on your cross-domain settings. Links between
www.example.comandblog.example.comcan be treated as internal when the tag treats them as the same site. Do not assume. Test the links in DebugView (covered later in this chapter). - Configured domains. If you list domains in the data stream's cross-domain measurement settings (under the Google tag settings), links to those domains are not treated as outbound. GA4 considers them part of your own site.
- Relative links. A link such as
/pricingstays on the current host, so it is never outbound. - Other protocols. Links such as
mailto:andtel:do not lead to another web domain. Do not rely on outbound click tracking for them. If you need them, use a custom event.
A link needs a real navigation target in its href. Buttons that run JavaScript and then change window.location are not links the tag can inspect, so they do not produce the automatic event.
<!-- Tracked: different domain, standard anchor element -->
<a href="https://partner.example.org/offer" id="partner-offer" class="cta">Partner offer</a>
<!-- Not tracked as outbound: same site -->
<a href="/pricing">Pricing</a>
<!-- Not tracked as outbound: no link target for the tag to read -->
<button onclick="window.location='https://partner.example.org/offer'">Partner offer</button>Turning the setting on or off
Outbound clicks is one of the enhanced measurement toggles. To check it:
- In GA4, open Admin.
- Under Data collection and modification, select Data streams.
- Select your web data stream.
- In Enhanced measurement, confirm the switch is on, then select the gear icon.
- Find Outbound clicks and switch it on or off.
- Select Save.
The setting applies only to this data stream. If you have several web streams, configure each one. The change takes effect for new data only. GA4 does not reprocess events that were collected before the change.
There is no separate option to list the domains you consider internal inside this panel. That is done through the cross-domain configuration, so keep both places in mind when a link is classified differently from what you expect.
Viewing the data in reports
New events usually take some time to appear in standard reports, so use DebugView for immediate checks. After that, you can find the event under Reports > Engagement > Events, where click appears in the list of event names.
The event parameters, such as link_url, are not available in standard reports by default. GA4 collects them, but to break down reports by link_url or link_domain you must register them as custom dimensions. Chapter 11 of this tutorial covers registration. In short, you create an event-scoped custom dimension under Admin > Custom definitions whose event parameter name matches the parameter, for example link_domain.
Without a custom dimension, you can still see the parameters in Explore reports in some cases and in DebugView. For routine reporting, register link_domain first. It has far fewer distinct values than link_url, which keeps reports readable and reduces the chance of hitting the cardinality limits that GA4 applies to dimensions with very many unique values.
Verifying outbound clicks
Use DebugView to confirm that a link behaves as you expect. The Google tag snippet below turns on debug mode for the page you load it on.
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', { debug_mode: true });
</script>Replace G-XXXXXXXXXX with your measurement ID. Then:
- Open Admin > DebugView in GA4.
- Load your page in another tab and click an external link.
- Watch for a
clickevent in the stream, and expand it to inspectlink_url,link_domainandoutbound.
Remove debug_mode when you are done testing, so that debug traffic does not stay flagged in production.
A practical test plan covers one example of each kind of link on your site:
- A plain external link.
- A link to a subdomain of your own site.
- A link to a domain you list for cross-domain measurement.
- A link that opens in a new tab.
- A link inside a menu or dynamically added component.
Record the expected and actual result for each. Surprises here are usually domain configuration issues rather than bugs.
What the event does not capture
The automatic outbound click event has limits that matter for planning:
- Navigation timing. The tag sends the event as the click happens. On a link that opens in the same tab, the browser can leave the page before the request completes. GA4 uses the browser's beacon transport to reduce lost hits, but you may still see small undercounts compared with server logs.
- Content you did not mark up. The event reports
link_idandlink_classesonly if the element has them. Many links have neither, which leaves those parameters empty and makes it hard to tell which button was clicked. - Different links to the same destination. If a page has a header link and a footer link to the same URL, the events differ only by the optional
link_classesandlink_id. Without them you cannot tell which placement drove the click. - Dynamic content. Links added after the page loads are generally covered, because the tag listens at the document level. Clicks inside iframes are not. The tag on your page cannot see clicks that happen inside another document.
- Name collision. The event name
clickis also a name that people use when building custom events. If a custom event uses the same name, the two sources mix in one report. Give custom events a distinct name.
Using outbound clicks as a conversion signal
By default, click is not a key event. If outbound clicks matter to your business, for example affiliate links, you can mark the event as a key event. But click covers every outbound link. Marking it as a key event treats a click on a social media link and a click on an affiliate link as equally valuable. For that reason, the better approach is usually to track the specific link with a custom event.
When the built-in event is too broad, use a custom event on the specific links. This sends a clearly named event with only the parameters you need.
document.querySelectorAll('a[data-track="pricing-cta"]').forEach((link) => {
link.addEventListener('click', () => {
gtag('event', 'cta_click', {
link_text: link.textContent.trim(),
link_url: link.href
});
});
});To use this pattern, add a data-track attribute to each link you care about, for example <a href="https://partner.example.org/offer" data-track="pricing-cta">. You can then mark cta_click as a key event without catching unrelated outbound links. Keep the custom event running alongside enhanced measurement only if you accept that the same click will then appear in two events. They have different names, so they do not conflict, but your totals for "all clicks" will not be additive.
The tutorial's later chapter on limitations and custom alternatives returns to when it is right to replace the automatic event entirely.
Common errors
| Symptom | Likely cause | What to check |
|---|---|---|
| No `click` events in DebugView | Outbound clicks toggle is off, or the link is not a standard anchor | Gear menu in the data stream; inspect the element's HTML |
| Links to your own subdomain appear as outbound | Subdomain is not covered by your cross-domain or domain settings | Cross-domain configuration for the stream |
| `link_url` is missing in reports | Parameter is not registered as a custom dimension | Admin > Custom definitions |
| Counts are lower than in other tools | Page unloads before the hit is sent, or ad blockers stop the tag | Compare with server logs; test with blockers off |
| Duplicate `click` events | The tag is installed twice, for example both gtag.js and Tag Manager | Page source and Tag Assistant |
Summary
- The
clickevent fires only for links that leave your domain, and it carrieslink_url,link_domain,link_id,link_classesandoutbound. - The tag compares the link's hostname with the current site and any domains you configured for cross-domain measurement.
- Test each kind of link in DebugView instead of assuming how subdomains behave.
- Register
link_domainas a custom dimension to report on destinations. - Use a custom event with a specific name when you need to measure one link or treat it as a key event.
Exercise
Your site is www.example.com. A page has a link to https://shop.example.com/cart, a link to https://partner.example.org/offer, and a <button> whose click handler sets window.location to https://partner.example.org/offer. Which of these might produce an automatic click event, and what should you do to be sure about the first one?
Show answer
The link to partner.example.org produces a click event, because it is a standard anchor to a different domain. The link to shop.example.com depends on your domain and cross-domain configuration, so load the page with debug_mode on and check DebugView to see whether a click event with outbound: true appears. The button produces no automatic event, because it is not an anchor with an href. To measure it, add a custom event in its handler.
Exercise
You want to report which destination domains visitors leave for, and you want a conversion count for only the affiliate link on your pricing page. What do you configure for each need?
Show answer
For destination domains, register link_domain as an event-scoped custom dimension in Admin > Custom definitions, then break down the click event by it. For the affiliate link, add a custom event such as cta_click on that link only and mark it as a key event, because marking the built-in click event would count every outbound link.