Skip to content
Browse documentation

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>:

HTML
<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.

AttributeRequiredDescription
data-offerRecommendedOffer code (or ID). Needed to record direct visits, and on a shared tracking domain to identify your workspace. When there is no click to join, /lp answers offer required without it. It is sent with conversions only when no click ID is known (direct and organic conversions); a known click already names its offer.
data-affNoPartner code for direct visits. Also read from an aff query parameter on the page URL.
data-paramNoName of the click-ID parameter in your landing-page URLs. Default click_id. Set it to the Click ID parameter name from Settings → Workspace if you changed that.
data-organicNotrue (also 1, yes, on) records visits that arrive without any click as clicks of your organic partner. See Organic visits.

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:

  1. Click ID in the page URL — the data-param parameter, then click_id, transaction_id, tid (32 hex characters). A partner's click therefore always replaces an older stored click.
  2. Google click ID in the page URL (gclid, gbraid or wbraid) — 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.
  3. Stored click ID from an earlier page view (local storage, else the atk_cid cookie on your domain).
  4. Organic visit — if data-organic is set: a new click of the organic partner.
  5. Direct visit — if data-offer is set: a new direct click for the offer (and data-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#

KeyWhereLifetimeContent
atk_cidLocal storage (+ atk_cid_exp) and a cookie on your domain (SameSite=Lax, Secure on HTTPS)30 daysThe current click (last touch)
atk_fcidSame30 daysThe first click stored in the 30-day window (organic clicks never count)

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:

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>
CallDescription
ArcTrack.clickId()The current click ID, or null.
ArcTrack.ready(fn)Calls fn(clickId) once the click ID is known (null if there is none).
ArcTrack.conversion({event, amount, txid, currency, …})Fires /px for the current click with click_id, first_click_id and every other scalar key you pass (for example adv1, coupon_code). token and click_id keys are ignored. The offer (data-offer, or an offer/offer_id you pass) is sent only when no click ID is known; with a click ID it is dropped, because the click names its offer — a smart link or another link may have sent the visitor to a different offer than the page's. A string argument is taken as the event code.
ArcTrack.decorate()Re-scans the page's links (see below).
ArcTrack.error()Why the last /lp call recorded no click (for example offer required), or null.
ArcTrack.push(item)Runs a queued ["method", args…] array or a function (same as ready).
ArcTrack.version"1".

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 href containing {click_id} (or %7Bclick_id%7D) gets the macro replaced;
  • any link with a data-atk attribute gets <name>=<click id> added or replaced, where <name> is the attribute's value, else data-param, else click_id.
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>

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

Organic visits#

  1. Go to Settings → Workspace → Organic traffic and turn on Record organic visits.
  2. Choose the Organic partner (an active house partner such as "Organic").
  3. Choose the Offer: a fixed offer, or The offer named by the page (data-offer).
  4. 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 ?aff=) 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.

Something unclear or missing in this article?Tell us