@n3oltd/link-builder
v2.0.0
Published
Captures utm_ and ntm_ campaign tags from the URL into the n3o_tags cookie
Readme
N3O tag capture
Captures campaign tags from the URL into the n3o_tags cookie, which the Umbraco checkout
reads and passes on to Engage.
This is transitional. It serves the sites still on the legacy Umbraco checkout; a site moving to platforms drops the script, and the package retires when the last one has moved.
What it captures
Every query parameter prefixed ntm_ or utm_, with the key kept exactly as it appears:
| URL parameter | Tag key | Tag value |
| --- | --- | --- |
| ntm_ad_campaign=Gaza+Emergency | ntm_ad_campaign | Gaza Emergency |
| utm_source=google | utm_source | google |
The prefix is part of the tag key and is never removed. utm_ is the industry-standard set;
ntm_ is N3O's own namespace, carrying the ad hierarchy the backend declares — ntm_ad_campaign,
ntm_ad_group and the rest — plus any custom key built in the link builder.
Getting this wrong fails quietly rather than loudly: nothing validates the prefix on the way in,
so a stripped ad_campaign is stored happily and simply never joins the ntm_ad_campaign
definition. The tag is there; the reporting is not.
There is no fixed list of names, so a new parameter needs no change here. Keys are lowercased and their punctuation normalised to underscores; values are kept as they are. Tags merge as a visitor moves around the site, the newest value winning per key, and the cookie lasts 90 days.
A key longer than 200 characters, or a value longer than 2000, is skipped — those are the limits the backend enforces, and a tag breaching them would be rejected on arrival.
How to use
No configuration is required.
<script>
(function (w, d, s, u) {
let f = d.body.getElementsByTagName(s)[0],
j = d.createElement(s)
j.async = true
j.src = u
j.type = 'text/javascript'
f.parentNode.insertBefore(j, f)
})(window, document, 'script', 'https://unpkg.com/@n3oltd/link-builder/umd/n3o-tags.js')
</script>API
window.n3o_tags:
| Member | Does |
| --- | --- |
| get() | Returns the stored tags as a flat object |
| add(key, value) | Sets one tag; removes it when value is empty. An unprefixed key gains ntm_ |
| capture() | Re-reads the current URL |
| init() | Kept because cooperating sites call it on load; there is nothing to configure |
Capture runs on load and on navigation, so calling anything by hand is optional.
Links built by the old in-page link builder
Those links carry their tag values in a single base64 ea parameter, keyed by number.
Such links are still in circulation — in sent emails, in ad platforms, in scheduled campaigns —
and cannot be recalled, so the script still reads them: ea is decoded and each dimension
becomes a tag keyed ntm_d0, ntm_d1 and so on, up to twelve.
The dimension names were held in per-subscription backend configuration that a browser
script cannot see, so only the number survives. The value — the part that identifies the
campaign — is preserved intact. An explicit ntm_/utm_ parameter on the same URL takes
precedence over a legacy dimension of the same name.
This can be removed once links carrying ea are out of use.
#linkbuilder
The link builder UI used to render inside the page on this hash. It has been replaced by the standalone app, so the hash now redirects to https://linkbuilder.n3o.cloud/eu1/.
