# How to track outbound link clicks without collecting private URLs

The CrispStats team · Published 2026-11-29 · Updated 2026-11-29

**TL;DR:** An outbound link click is a click on an http or https link whose host is not the host of the current page. The next page belongs to someone else, so a pageview never records it, and a click on your own button is a different event. Store the destination host. Do not store the full URL when the query string, the fragment or the path can contain an email address, a reset token or a signed download.

A pageview ends at your domain. The click that leaves, toward a docs site you do not host, a partner, an app store or a calendar, is invisible unless you record the click itself. This guide defines that click, says what to store, and shows a listener that sends the host and nothing else. The glossary entry for an [outbound link](/glossary/outbound-link) is the short definition. [How to track button clicks](/blog/how-to-track-button-clicks) is the other event: a control that stays on your site.

## What counts as an outbound link click?

A click on a link whose destination host differs from the current page's host, when the link is http or https. Same host means it is not outbound, even if the path is new.

- **Outbound.** `https://docs.partner.com/guide` clicked from `https://example.com/blog`. The hosts differ.
- **Not outbound.** `https://example.com/pricing` clicked from `https://example.com/blog`. The next pageview on your own site is the record.
- **A subdomain is a decision.** `docs.example.com` clicked from `www.example.com` is outbound under a strict host check, and internal if you treat the whole site as one. Decide once and keep it. If both hosts run the same analytics script, you already see the arrival as a pageview and may not need an outbound event.
- **Not a link click.** `mailto:` and `tel:` are not http links. A mailto link also contains an email address, which does not belong in analytics. Count them as their own events, with no address, or do not count them.

A middle click and a modified click open the destination in a new tab. They are still outbound clicks. A listener that only watches the ordinary click event misses the middle button. Count that click as well, or the people who open links in tabs disappear.

## Why track outbound clicks at all?

Because the outcome you care about happens on a site that will not send you a pageview. The click is the last fact you can observe.

Typical uses are a partner or affiliate link, a documentation site on another domain, a community, or a booking page. The click is intent, not the sale, the signup or the meeting. The partner's report is still the record of what happened after the click. Your event answers a narrower question: which of your pages, and which of your links, send people away.

Without the event, a high exit rate on a resource page looks like a failure. With it, you can see that most of those exits were the link the page was written to offer. That is the difference between a page that leaks and a page that does its job.

## What should the event contain?

The destination host is enough to answer which site people left for. Add a path only when you already know the path is public and stable, such as a documentation article. Do not send the full URL if it can contain an email, a token or a signed query.

Prefer the first row whenever the link is generated per visitor.

| What you send | What you can learn | What can leak |
| --- | --- | --- |
| Host only | Which external site was clicked | Nothing from the path or the query |
| Host and a public path | Which article or product page | A token or an email, if one was built into the path |
| Full URL, with query and fragment | The exact link, including campaign tags | Reset tokens, inbox links, signed downloads, and addresses in the query |

Query strings are the common leak. A newsletter tool that appends the subscriber's email, a password-reset link, or a download signed with a token, all look like ordinary URLs. The fragment is the other one: `#access_token=` never appears in a server log and still identifies the holder. [PII in analytics](/blog/pii-examples-in-analytics) is the longer list of how those values get into a report.

> **The href is not a label.** An affiliate link is still a private URL when your email tool adds the reader's address to it. Store the partner host, or a slug you assigned yourself. Do not store the href the browser actually followed.

## How do you send the click without the full URL?

Listen for clicks on links, compare hosts, and send an event whose only property is the destination host.

The call is `crispstats("outbound click", { host: url.host })`. `host` is the hostname and port, never the path or the query. The same shape works with any tracker that accepts an event name and flat properties: pass the host, and do not pass `link.href`.

```js
document.addEventListener("click", function (event) {
  var el = event.target;
  var link = el && el.closest ? el.closest("a") : null;
  if (!link) return;
  var url;
  try {
    url = new URL(link.href, location.href);
  } catch (err) {
    return;
  }
  if (url.protocol !== "http:" && url.protocol !== "https:") return;
  if (url.host === location.host) return;
  crispstats("outbound click", { host: url.host });
});
```

Put the listener once, on the document, not on each link. Links added later, including links inside a post body, are covered because the click bubbles. Skip the listener entirely if the tool already records outbound clicks and you have checked what it stores. Two listeners send two events.

- **Name the link yourself when the host is not specific enough.** Two links to the same partner host need a property you control, such as `slot: "footer"`, set in your HTML. Do not derive that label by reading the query string.
- **Ignore your own domains on purpose.** If the blog and the app are different hosts and both carry the script, a strict check records a click you will also see as a landing pageview. Drop hosts you own, or accept the double record and do not add the two numbers together.
- **Do not read the link text into the event if the text is an email address.** A link whose visible label is `ada@example.com` is personal data even when the property you meant to send was the host.

## How is this different from a button click?

A button click is a control on your site: a toggle, a signup, a tab. An outbound click is a departure. They answer different questions and should not share an event name.

Mixing them produces a report where "click" means everything. A pricing toggle and a partner link then look like one feature. Keep `outbound click` for leaving the host, and use a specific name for each of your own controls, as in [how to track button clicks](/blog/how-to-track-button-clicks). A link to your own `/signup` is a button-style event, or just the next pageview. It is not outbound.

## What does a resource page's outbound traffic look like?

Group the clicks by host, then divide by the pageviews of the page that offered the links. The rate is about the page. The split across hosts is about which link earned the click.

### A worked example: three external links

This example uses made-up numbers. A tools page gets 4,000 pageviews in a month. The listener records 220 clicks to `calendar.example`, 140 to `github.com`, and 40 to `status.example`. No query strings were stored.

Outbound clicks are 400. The outbound click rate is 400 ÷ 4,000 = 10%. The calendar link is 220 ÷ 400 = 55% of the exits. That is the link to test first, by position or label. It is not a conversion rate: the meetings booked are in the calendar product, not in this event. If the calendar links had been stored in full, and each one carried the visitor's email as a query parameter, the analytics tool would now hold 220 addresses. The host-only event does not.

## How does CrispStats record outbound clicks?

Turn on outbound clicks with `data-outbound` on the script tag. A click or a middle click on an http or https link to another host sends an event named Outbound link. The destination is a `url` property with the fragment removed and the query string cut the same way as the page URL, so parameters other than campaign tags are dropped. Mailto and tel links are not included. The core script without that module is about 2.2 KB gzipped.

```html
<script defer src="https://in.crispstats.com/d.js" data-outbound data-site="YOUR_SITE_KEY"></script>
```

That automatic URL is safe for a public article and unsafe for a link that embeds a secret in the path, because the path is kept. When the href can contain an email or a token, do not use the module for those links. Send `host` yourself with `crispstats("outbound click", { host })`, and keep the automatic module off, or you will store both. The event is a custom event: it counts toward the plan, and a session that only fires it is not a bounce.

## Frequently asked questions

### What is an outbound link click?

A click on an http or https link whose host is different from the current page. A link to another path on the same host is an ordinary navigation, not an outbound click.

### Should I store the full destination URL?

No, if the URL can contain an email, a token or a signed query. Store the destination host. Add a path only when you know that path is public. Drop the query string and the fragment.

### Is a subdomain an outbound link?

Under a strict host comparison, yes, because docs.example.com and www.example.com are different hosts. If you consider them one site, exclude that host. Write the rule down so every page uses it.

### Do mailto links count as outbound clicks?

No. They are not http links, and the address is personal data. Do not send the mailto href to analytics. Count a separate event with no address if you need the volume.

### Does an outbound click mean the visitor converted?

No. It means they followed the link. The signup, purchase or booking happens on the other site and has to come from that site's report. Use the click to see which link is doing the sending.
