Landing-page SDK
Install sdk.js to keep the click ID on your own domain, join Google Ads clicks by gclid, record direct and organic visits and fire conversions.
Last updated 6 min read
On this page
The landing-page SDK is a small script (ES5, no dependencies) served by your tracking domain at /sdk.js. On every
page of the landing site it:
- finds the visit's click ID — from the URL, from a Google click ID (parallel tracking), or from earlier storage;
- stores it in first-party storage on your domain for 30 days, so it survives cookie restrictions on the tracking domain;
- records direct visits (no tracking link) and, optionally, organic visits as clicks;
- passes the click ID on to checkout or sign-up links;
- fires conversion pixels through its JavaScript API (
ArcTrack.conversion()).
Install#
Add the script to every page, before </body>:
<script async src="https://trackcrown.com/sdk.js" data-offer="SHOP01"></script>Load it from the tracking domain your links use: the SDK sends its requests to the host it was loaded from.
How the click ID is found#
On every page load the SDK runs these steps and stops at the first that gives a click ID:
- Click ID in the page URL — the
data-paramparameter, thenclick_id,transaction_id,tid(32 hex characters). A partner's click therefore always replaces an older stored click. - Google click ID in the page URL (
gclid,gbraidorwbraid) — the SDK asks the tracking domain for the click that the Google Ads tracking template recorded (the parallel-tracking join, see the /lp endpoint). If nothing matches, it keeps the stored click ID, if any. - Stored click ID from an earlier page view (local storage, else the
atk_cidcookie on your domain). - Organic visit — if
data-organicis set: a new click of the organic partner. - Direct visit — if
data-offeris set: a newdirectclick for the offer (anddata-aff, when given and approved).
Requests to the tracking domain time out after 5 seconds; on a timeout the SDK continues without a click ID.
Storage#
When the current click differs from atk_fcid, conversions carry first_click_id. Which one gets credit is the
workspace's attribution model (Settings → Conversion rules → Attribution: Last touch or First touch).
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 pushed before the script has loaded are queued:
<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>SDK conversions are pixel conversions: the offer's Conversion tracking must allow pixels, and the rules of
pixels apply (no status, no payout). A conversion without a click ID is
refused with click_id required unless the tracking domain's pixel cookie identifies the visit.
Troubleshooting#
The SDK never breaks your page. When /lp records no click it logs a warning on the browser console, prefixed with
the SDK object name ArcTrack: — the HTTP status and the error, for example no click recorded: … answered HTTP 400 "offer required",
with a hint to add data-offer to the script tag — and ArcTrack.error() returns the same text. A timeout or network
error is logged as … /lp did not answer; no click recorded.
Passing the click ID on#
Once the click ID is known the SDK rewrites links (and again on click, for links added later):
- any
hrefcontaining{click_id}(or%7Bclick_id%7D) gets the macro replaced; - any link with a
data-atkattribute gets<name>=<click id>added or replaced, where<name>is the attribute's value, elsedata-param, elseclick_id.
<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>javascript:, mailto: and tel: links are never touched.
Organic visits#
- Go to Settings → Workspace → Organic traffic and turn on Record organic visits.
- Choose the Organic partner (an active house partner such as "Organic").
- Choose the Offer: a fixed offer, or The offer named by the page (data-offer).
- Add
data-organic="true"to the SDK tag.
An organic click gets sub1 = the source platform derived from the referrer (google, bing, duckduckgo,
yahoo, yandex, baidu, facebook, instagram, x, linkedin, reddit, youtube, tiktok, pinterest,
chatgpt, else referral, or direct without a referrer), sub2 = the referring host and sub3 = the landing
path, unless the landing URL already set them. A visit that names a partner (data-aff or ?) is recorded as
a direct click for that partner, not as organic. A later partner click always takes over.
Privacy#
The SDK stores only the random click ID. List atk_cid and atk_fcid in your cookie notice and ask for consent
where your law requires it.