Skip to content

Tracker (JavaScript pixel)

Add the script on every page of the website (ideally in the <head>):

<script async src="https://tracker.adstrike.io/t.js?id=SITE_ID"></script>
  • SITE_ID is the site’s identifier, visible in the dashboard (site settings).
  • The script is served by the API (GET /t.js), which checks that the calling domain (Referer header) belongs to the site’s acceptedDomains — a valid identifier on an undeclared domain returns a 404.
  • Custom CNAME domains are supported (certificates managed automatically): replace tracker.adstrike.io with your CNAME.

The script injects the site configuration (window._ADSTRIKE_CONFIG) then the tracker. Events are queued locally and sent in batches to POST /c (1 s debounce, forced flush on page unload and when the tab goes to the background).

Event Trigger
page_view On every page load and every SPA navigation (pushState, replaceState, popstate, pageshow are intercepted). Deduplicated when the URL has not changed. Requires page_view tracking to be enabled in the site configuration
session_start When a new session starts (30 min of inactivity = new session). Carries the landing attribution data (referrer, UTM, click IDs when consented). In anonymous mode, deduplication happens server-side
consent_upgrade When a visitor moves from “denied” to “granted” (links the anonymous session)
Configured events The dashboard lets you configure DOM listeners (CSS selector + event type) without touching the website

Once the tracker is loaded, window.as(eventName, params) is available:

window.as("add_to_cart", { sku: "TSHIRT-42", value: 29.9, currency: "EUR" });

Pixel-side purchase event contract:

window.as("purchase", {
tid: "ORDER-10042", // order id — deduplication key
value: 129.5, // order amount
currency: "EUR" // ISO 4217
});
  • tid is the order identifier, unique per site. It is the deduplication key between the pixel and the Conversions API: the same order sent through both channels is counted once.
  • value and currency feed the attributed revenue (automatic conversion into the account’s base currency).
Section titled “Identification (identify) — recommended pattern: the pre-init command queue”

The tracker loads asynchronously. A direct window.adstrike.identify(...) call fired by your app’s authentication bootstrap can run before the tracker has loaded — it would then be lost. Use the adstrikeQ command queue, which works before and after the tracker has loaded:

// At login (or on page load when the user is already logged in)
(window.adstrikeQ = window.adstrikeQ || []).push(["identify", "USER_12345"]);
// At logout
(window.adstrikeQ = window.adstrikeQ || []).push(["resetIdentity"]);

On load, the tracker drains the queue then replaces push with a proxy that executes commands immediately: the same code works regardless of load order.

About the clientId passed to identify():

  • Opaque identifier (your internal user id — never a cleartext email). Max 256 characters; allowed characters: letters, digits, . @ : = _ -.
  • With consent: stored in the _astr_cid cookie (persists across pages). Without consent: kept in memory for the current page only.
  • Powers cross-device tracking (sessions sharing a clientId are linked for attribution) and serves as the join key for the Conversions API.
  • resetIdentity clears the cookie at logout so later sessions are not linked.

Automatic detection, no integration needed if you use:

  • Google Consent Mode: the tracker reads dataLayer (consent default / consent update) and observes updates. Consent is granted when analytics_storage or ad_storage is granted.
  • IAB TCF 2.0 (__tcfapi): purposes 1, 7 or 8.

For a custom banner, call the custom API:

window.adstrike.setConsent(true); // granted
window.adstrike.setConsent(false); // denied

Behavior:

  • Without any signal after 5 seconds, consent switches to “denied” (anonymous mode, see Platform architecture).
  • Events emitted while waiting are queued and sent once consent is resolved.
  • A denied → granted transition is handled (cookies are created and the anonymous session is linked).
  • Other available methods: window.adstrike.getConsent(), window.adstrike.onConsentChange(cb), window.adstrike.flush().

No cookie is set until consent is granted.

Cookie Lifetime Contents
_astr_vid ~13 months Visitor identifier (UUID)
_astr_sid 30 minutes, extended on activity Session identifier (UUID)
_astr_cid ~13 months clientId passed to identify() (cross-device)

Attributes: Path=/; Secure; SameSite=None.