Best practices for outbound link attribution

Five practices, in order of impact. Each maps to tests in the test catalog.

1. Send the origin as the referrer

Tests: REF-01, REF-02, REF-03.

The referrer is the oldest attribution signal on the web, and every analytics tool reads it. Send the origin only, such as https://chatgpt.com/, never the conversation URL.

<meta name="referrer" content="strict-origin-when-cross-origin">
<a href="https://example.com/article" target="_blank" rel="noopener">Example</a>

2. One documented UTM value

Tests: UTM-01, UTM-02, UTM-03.

Apps, webviews and some browsers can't send a referrer. A utm_source parameter works everywhere.

3. Merge safely

Tests: MRG-01, MRG-02, MRG-03, MRG-04.

Adding a parameter to someone else's URL must never break it.

Reference implementation (JavaScript):

const SIGNED = /^(signature|sig|token|expires|x-amz-|x-goog-)/i;

export function addAttribution(rawUrl, source, medium) {
  let url;
  try { url = new URL(rawUrl); } catch { return rawUrl; }
  if (!/^https?:$/.test(url.protocol)) return rawUrl;
  const keys = [...url.searchParams.keys()];
  if (keys.some((k) => SIGNED.test(k))) return rawUrl; // MRG-04
  if (keys.some((k) => k.toLowerCase().startsWith('utm_'))) return rawUrl; // MRG-03
  let tag = `utm_source=${encodeURIComponent(source)}`;
  if (medium) tag += `&utm_medium=${encodeURIComponent(medium)}`;
  // Append to the raw query: searchParams would re-encode existing parameters. MRG-01
  url.search = url.search ? `${url.search}&${tag}` : `?${tag}`;
  return url.toString(); // URL keeps the hash after the query. MRG-02
}

The test vectors cover each rule.

A note on choices: skipping the tag whenever any utm_* parameter exists is the conservative option. It never touches a site's campaign data, but it also means links that already carry, say, only utm_campaign get no source from you. An alternative is to add utm_source only when it is missing. We'd like to hear from labs and sites on which works better in practice.

4. Per-surface options

5. Publish a changelog

Test: OPS-01.

Link behavior changes with UI updates. A short, dated public note ("from October 20, links in research reports carry the referrer") lets websites tell a product change from a real change in traffic, and saves both sides a week of guessing.

6. Side effects and how sites handle them

Tagging links has small side effects that sites already know how to manage.