Skip to content
Browse documentation

Landing-page SDK reference

The sdk.js script and the /lp endpoint — install attributes, how the click ID is found and stored, the JavaScript API (window.ArcTrack), link decoration and every /lp answer.

Last updated 6 min read

On this page

The landing-page SDK is a small script (ES5, no dependencies) served from your tracking domain at /sdk.js. It keeps the click ID available on your landing site, joins Google Ads parallel-tracking clicks by gclid, records direct and organic visits, decorates links and fires conversions from the browser.

Install#

Add the script to every page of your landing site — in the <head> or before </body>:

HTML
<script async src="https://trackcrown.com/sdk.js" data-offer="OFFERCODE"></script>
AttributeDescription
data-offerOffer code (or ID). Needed to record direct visits (no click ID, no Google click ID); without it /lp answers offer required when nothing joins. Sent with conversions only when no click ID is known — never with the conversion of a known click.
data-affPartner code for direct visits. Also read from an aff query parameter of the page URL.
data-paramName of the click-ID parameter in your landing-page URLs. Default click_id.
data-organictrue (or 1, yes, on) to record visits that arrive without any click as clicks of the workspace's organic partner (Settings → Workspace → Organic traffic).

Load the script once per page; a second copy does nothing.

How the click ID is found#

When the page loads, the SDK checks, in this order:

  1. A click ID in the page URL — the data-param parameter, then click_id, transaction_id, tid (32 hex characters). It is used as is.
  2. A Google click ID — gclid, gbraid or wbraid in the URL. The SDK asks the tracking domain (POST /lp) for the click recorded by the tracking template's background request — this is how parallel tracking is joined. If nothing is found, it falls back to a stored click ID.
  3. A stored click ID from an earlier visit (local storage, else the atk_cid cookie).
  4. Organic — with data-organic and an organic partner configured, a new organic click is recorded: sub1 = the source platform from the referrer (google, bing, facebook, x, referral or direct), sub2 = the referring host, sub3 = the landing path.
  5. Direct — with data-offer, a new direct click is recorded for the offer (and data-aff).

Otherwise there is no click ID (ArcTrack.clickId() returns null). The /lp request times out after 5 seconds.

Storage#

KeyWhereContentLifetime
atk_cidlocal storage (+ atk_cid_exp) and a first-party cookie (SameSite=Lax, Secure on HTTPS)the current (last) click ID30 days
atk_fcidsamethe first non-organic click of the 30-day window30 days

A partner's click always wins: a visitor who later arrives through a partner link replaces the stored organic click. When the first click differs from the current one, conversions carry it as first_click_id; your workspace's attribution model (Settings → Conversion rules: last touch by default, or first touch) decides which is credited.

JavaScript API#

The SDK exposes one global object, window.ArcTrack. ArcTrack is a fixed technical name of the tracking engine — the same on every installation, whatever your brand — so your code never changes when the brand does. Calls made before the script has loaded are queued:

HTML
<script>
  window.ArcTrack = window.ArcTrack || [];
  ArcTrack.push(["conversion", { event: "sale", amount: "49.90", txid: "ORDER-1001", currency: "USD" }]);
  ArcTrack.push(function (clickId) { console.log("click", clickId); });
</script>
<script async src="https://trackcrown.com/sdk.js" data-offer="OFFERCODE"></script>
CallDescription
ArcTrack.clickId()The current click ID, or null (also null before resolution).
ArcTrack.ready(fn)Calls fn(clickId) once the click ID is known (null when there is none).
ArcTrack.conversion({…})Fires a conversion for the current click. Queued until the click ID is known.
ArcTrack.decorate()Re-scans the page's links (see below).
ArcTrack.error()Why /lp recorded no click (the text also logged with console.warn), or null.
ArcTrack.push(item)Runs ["method", …args] or a function (= ready). Works before and after loading.
ArcTrack.version"1".

conversion()#

ArcTrack.conversion(params) requests https://trackcrown.com/px?js=1&click_id=…&… as an image. It sends:

  • click_id (when known) and first_click_id (when it differs);
  • offer = data-offer only when no click ID is known (direct and organic conversions), unless you pass offer/offer_id yourself. With a click ID no offer is sent — also not an offer/offer_id you pass — because the click names its offer, and a different offer would be refused with offer_id does not match the click;
  • aff = data-aff, unless you pass aff/aff_id yourself;
  • every other key of params as a query parameter — event, amount, txid, currency, adv1…adv5, email, coupon_code and so on (objects, functions and the keys click_id, token, js are skipped);
  • a random r cache buster.

These are pixel conversions (method js): the offer's conversion method must allow pixels (any or pixel). Parameters: Conversion pixels.

Passing the click ID on#

The SDK rewrites links when the click ID is known, and again on every link click (so links added later are covered):

  • a link whose href contains {click_id} (or %7Bclick_id%7D) gets the macro replaced;
  • a link with a data-atk attribute gets click_id=<id> set — or the parameter named in data-atk (an existing value is replaced, a #fragment kept).

javascript:, mailto: and tel: links are never touched.

HTML
<a href="https://checkout.example.com/buy?ref={click_id}">Buy now</a>
<a href="https://app.example.com/signup" data-atk="aid">Sign up</a>

The /lp endpoint#

The SDK talks to POST https://trackcrown.com/lp. You can call it from your own code. CORS is open, no credentials are needed, and the body may be sent as text/plain (no CORS preflight).

Request body (JSON):

FieldDescription
click_idA click ID from the page URL.
gclid, gbraid, wbraidGoogle click identifiers from the page URL.
offerOffer code or ID.
affPartner code or ID.
organictrue to allow an organic click.
url, referrerThe page URL and document.referrer.

Answer: {"click_id": "…", "source": "…"}, decided in this order:

Request carriesAnswersource
click_id (32 hex)the same click IDparam
gclidthe newest click with that gclid — in the offer's workspace when offer is given (within its attribution window), in the domain's workspace on a workspace domain, otherwise in any workspace of the brand on a shared brand domain (90 days)gclid
gbraid or wbraidthe newest click with that ID in the workspace (needs offer or a workspace domain)gbraid / wbraid
nothing joins, organic: true, organic partner configureda new organic clickorganic
nothing joins, offera new direct click for the offer (and aff)direct

The direct click maps the page URL's query parameters onto the click like a tracking link (sub IDs, ValueTrack values, gclid). A click found by gclid is returned immediately, even while it is still being written to the reporting database.

Errors are JSON {"error": "…"}:

Statuserror
400invalid body, invalid click_id, offer required (nothing joined and no offer), unknown offer, offer not active, workspace not active, this tracking domain does not serve the offer, gclid too long, unknown affiliate, affiliate not active, affiliate not approved for this offer
405method not allowed
503configuration not loaded, click store unavailable

The SDK reports every failed /lp call on the browser console (console.warn, prefixed with the SDK object name ArcTrack:) with the HTTP status and error — for offer required with the hint to add data-offer="OFFERCODE" to the script tag — and ArcTrack.error() returns the same text. A timeout or network error is reported too. The page itself is never affected.

Example — parallel tracking on a shared brand domain, where the page only knows the gclid:

Shell
curl -s https://trackcrown.com/lp -H 'Content-Type: text/plain' \
  -d '{"gclid":"EAIaIQobChMI","url":"https://www.example.com/?gclid=EAIaIQobChMI"}'
# {"click_id":"0192f3c1a2b4e1f0c9d84b2a7e6f5d3c","source":"gclid"}

Clicks a Google Ads tracking template sends through the tracker store the gclid, gbraid and wbraid that auto-tagging adds to the landing page (the url= value), so templates never need {gbraid} or {wbraid} tags.

Privacy#

The SDK stores only the random click IDs (atk_cid, atk_fcid) on your domain. Mention them in your cookie notice and ask for consent where your law requires it.

See also: Parallel tracking · Final URL suffix + SDK.

Something unclear or missing in this article?Tell us