N Docs
← Back to site

The bridge script

2 min readUpdated November 23, 2026
<script async src="https://go.yourbrand.com/_nl/bridge.js"></script>

Any of your short domains, or the edge script address, works. In the page:

APIWhat it gives
NahnuLinks.click()The click ID for this tab, or null.
NahnuLinks.link()A promise of the short link’s details, or null when the visit isn’t from a short link.
NahnuLinks.ready(cb)Calls cb(details) once known.
nahnulinks:clickFired on document once per click, on landing, with the details in event.detail.
document.addEventListener('nahnulinks:click', (e) => {
  myAnalytics.track('Short link visit', { link: e.detail.short_url, route: e.detail.route });
});

The details:

{ "click": "Hk2v9QzL0aP3xT7m", "link_id": 991, "short_url": "https://go.acmebakery.example/spring", "slug": "spring", "domain": "go.acmebakery.example", "title": "Spring sale", "clicked_at": 1794938110, "route": "ab:2", "utm_source": "newsletter", "utm_medium": null, "utm_campaign": null }

Add data-track="Short link visit" to the script tag to have it call window.NahnuAnalytics.track() with that event name, for tools without built-in support yet.

GET /_nl/click/{id} gives the same details. It’s public, because click IDs can’t be guessed, and holds nothing about the visitor.

Where to put it#

As early as possible in the page’s <head>, before your analytics script, so the click ID is read before anything else sees ?nlc= in the address. For the fastest hand-over, add the one-line inline snippet shown under Settings > General > Analytics connections right before it: it moves the click ID out of the address straight away, even before the script has loaded.

On WordPress sites with Nahnu Links Client, the bridge is added for you.

Examples#

Google Analytics 4

NahnuLinks.ready(function (d) {
  if (!d) return;
  gtag('event', 'short_link_visit', { link_url: d.short_url, link_title: d.title, route: d.route });
});

Plausible

NahnuLinks.ready(function (d) {
  if (d) plausible('Short link visit', { props: { link: d.short_url } });
});

Add the link to a form, so leads show their source

NahnuLinks.ready(function (d) {
  var f = document.querySelector('input[name="source_link"]');
  if (d && f) f.value = d.short_url;
});

Good to know#

  • The details are cached for the tab, so moving between pages doesn’t ask again.
  • nahnulinks:click fires once per click, on landing, not on every page.
  • Visits that don’t come from a short link get null, and no event.
  • It sets no cookies.