Skip to content

@xtandard/links/client

Browser helper for conversion attribution (ADR 0010) — the open equivalent of @dub/analytics’s click-id capture. Zero dependencies, ~1 KB.

Call captureClickId once on page load of the destination site: it reads the click id the redirect appended (?xl_id=clk_…), stores it in a first-party cookie and removes it from the address bar. Later, send getClickId with your signup request so the server can call core.trackLead({ clickId, customerId }).

import { captureClickId, getClickId } from "@xtandard/links/client";
captureClickId();
await fetch("/signup", { method: "POST", body: JSON.stringify({ email, clickId: getClickId() }) });
import { … } from "@xtandard/links/client";
Name Summary
captureClickId Capture the click id from the current URL into a cookie. Returns the click id in effect (newly captured or previously stored), or undefined.
clearClickId Forget the stored click id (e.g. after a successful lead).
getClickId The stored click id, if any.
Name Summary
CaptureOptions Options for captureClickId.