Install the Capture Script
When conversion tracking is on for a link, Shortn adds a click id to the destination URL:
https://example.com/signup?snt_click_id=clk_...Add the capture script to the destination site so it can keep the click id until signup or checkout:
<script
src="https://app.shortn.link/static/js/conversion-capture.js"
data-track-endpoint="/api/shortn-conversion"
data-consent-cookie="shortn_consent"
data-form-enrichment="true">
</script>The script reads snt_click_id from the URL and keeps it in a first-party cookie and
localStorage (shortn_click_id), with any UTM parameters (shortn_utm_params). It keeps
the click id for its attribution window, at most 90 days. Whether a newer click replaces the
stored one follows the workspace’s attribution model (first or last touch).
Consent
By default the script stores nothing until the visitor consents
(data-consent-mode="required"). Grant consent in one of two ways:
- From your consent banner: call
window.shortn.conversion.grantConsent()when the visitor accepts, andrevokeConsent()when they withdraw. CallsyncConsent()after your banner changes its own cookie. - Through a cookie: set
data-consent-cookieto a cookie your consent tool writes. The valuev1.grantedturns capture on andv1.deniedturns it off (change them withdata-consent-granted-valueanddata-consent-denied-value).
If your site does not need consent for this purpose, set data-consent-mode="not-required"
(without data-consent-cookie). getConsentState() returns the current state.
Form enrichment
With data-form-enrichment="true", the script adds hidden shortn_click_id and UTM fields
to forms on the page, including forms added later. It only passes on values from the URL; it
does not collect location, device, browser, page URL or referrer. Add
data-shortn-ignore="true" to a form to skip it.
Checkout links
The script adds the stored click id to Dodo Payments checkout links and Stripe Payment Links
when a visitor follows them. Set data-checkout-links="false" to turn this off. See
Attribute hosted checkouts for
every checkout flow.
Browser API
const clickId = window.shortn.conversion.getClickId();
const attribution = window.shortn.conversion.getAttribution(); // { click_id, utm }
Use these only to pass the click id to your own backend. trackLead, trackSale and
convert post events to data-track-endpoint on your site; see
Send conversion events. Other
functions: capture(), clearClickId(), clearAttribution(), checkoutURL(url) and
subscribe(callback).
Attributes
| Attribute | Default | Description |
|---|---|---|
data-track-endpoint | none | Your backend endpoint that forwards events to Shortn. Required for trackLead, trackSale and convert. |
data-consent-mode | required | required or not-required. |
data-consent-cookie | none | Cookie your consent tool writes. |
data-consent-granted-value | v1.granted | Cookie value that grants consent. |
data-consent-denied-value | v1.denied | Cookie value that denies it. |
data-cookie-domain | current host | Share the cookie across subdomains, for example .example.com. |
data-cookie-days | 90 | How long to keep the click id, 1 to 90 days; never longer than the click’s attribution window. |
data-custom-utm-params | none | More UTM-style parameters to keep, comma-separated, for example utm_team,utm_variant. |
data-form-enrichment | false | Add hidden click id and UTM fields to forms. |
data-checkout-links | true | Add the click id to Dodo Payments and Stripe checkout links. |
data-debug | false | Log what the script does to the browser console. |
Cloaked links
The capture script can’t reliably keep the click id for links with cloaking on: the destination runs inside a frame, and browsers keep framed storage apart. Turn off cloaking for links you track conversions on.