Skip to content

Tracker protocol

The amabledata tracker is a small first-party JavaScript file that you add to your website. It records pageviews, goals, identities, payments and outbound links, captures ad click ids and UTM parameters, links visitors across your domains and to funnel tracking links, and sends everything to the edge worker of your installation. The edge enriches the events (geo, device, channel), filters bots and stores them in the analytics of the site.

This page is the technical contract: script variants, attributes, the JavaScript API, cookies and storage, the exact payload of POST /e, and the server-side ingest for backends. For installing the snippet step by step, see Install the tracker.

Where to get the snippet in the app: the analytics settings, Sites tab, or the API GET /api/v2/t/<workspace>/analytics/sites/{siteId}/snippet. Every site has a public site id (st_ followed by 20 characters) and a server secret for backend events.

The edge serves three builds of the tracker, from your edge origin (the tracking subdomain of your installation, or a custom tracking domain of the site):

Path Cookies Routing Use it when
/s.js First-party cookies (none when the site is cookieless, see Site mode check) Path changes (pushState, popstate) Default for most sites.
/s.cookieless.js None Path changes You do not want any cookie or browser storage. The server derives a daily visitor hash instead.
/s.hash.js First-party cookies (none when the site is cookieless) Path and #/route changes; the hash stays in the page URL Single-page apps that route with the URL hash.

The scripts are served with Cache-Control: public, max-age=3600, stale-while-revalidate=86400, an ETag (conditional requests answer 304), Access-Control-Allow-Origin: * and Cross-Origin-Resource-Policy: cross-origin.

<script>window.amable=window.amable||function(){(window.amable.q=window.amable.q||[]).push(arguments)};</script>
<script defer data-site="st_abcdefghijklmnopqrst" src="https://track.example.com/s.js"></script>

The first line installs a stub: calls to amable(…) made before the script loads are queued in amable.q and replayed, in order, once the tracker boots. Sites set to cookieless get /s.cookieless.js in their snippet; a /s.js or /s.hash.js snippet pasted earlier detects the mode by itself.

Attribute Default Effect
data-site required The public site id. Without it the tracker stays off (no_site).
data-api <script origin>/e Ingest endpoint. Set it when you proxy the endpoint through your own domain.
data-domain the registrable root domain, found automatically Cookie domain. The tracker finds it by writing a probe cookie from the shortest candidate upwards (so shop.example.co.uk uses example.co.uk). Set it to force a domain.
data-allow-localhost off Track on localhost, *.localhost, 127.0.0.1, ::1, 0.0.0.0 and file: pages. The site must also allow localhost on the server.
data-allow-iframe off Track when the page is inside an iframe.
data-cross-domain none Comma-separated hostnames of your other domains. Links to them (and their subdomains) carry the visitor and session ids.
data-no-external-links off Do not send external_link events.
data-no-forms off Do not capture emails and phone numbers typed into form fields.

The tracker reads these attributes from its own script tag, or from the first script[data-site] on the page.

The tracker checks these conditions at boot and, if one matches, writes no cookie and sends no event. With no_site, opted_out and bot it sends no request at all; with iframe and localhost the cookie builds still make the site mode check first, because it runs before these two checks.

Reason Condition
no_site No data-site attribute.
opted_out localStorage.amable_ignore is "true" in this browser.
bot navigator.webdriver is true, the user agent looks automated (bot, crawler, spider, headless browsers, testing and scraping tools, command-line HTTP clients), or automation globals are present.
iframe The page is framed and data-allow-iframe is not set.
localhost The page is local and data-allow-localhost is not set.

When the tracker is off, amable('optin') still works, so an opt-out link can be undone.

The cookie builds use four first-party cookies, set with path=/, SameSite=Lax, the cookie domain, and Secure on HTTPS pages:

Cookie Content Lifetime
amb_vid Visitor id, a random UUID 365 days, renewed on every event
amb_fs First-seen time of the visitor (ms) 365 days
amb_sn Session number of the visitor (1 = first session) 365 days
amb_sid Session id: s followed by 32 hex characters 30 minutes, sliding: every event extends it

When amb_sid is missing (30 minutes without events), the next event starts a new session and increments amb_sn. An invalid or missing amb_vid creates a new visitor.

The cookie builds also keep the funnel context of the visit in sessionStorage (key amb_dl). The opt-out flag lives in localStorage (amable_ignore).

Cookieless build (and the cookie builds on sites configured as cookieless): no cookie and no storage is written. Each event carries cl: 1, and the edge computes the visitor id as h followed by 32 hex characters of a SHA-256 of a random per-site salt, the site id, the IP address and the user agent. The salt changes every UTC day and is deleted after two days, so the same person gets a new id every day and the id cannot be recomputed from an IP address later. Sessions, session numbers and cross-domain linking are not available in this mode.

The cookie builds (/s.js, /s.hash.js) ask the edge for the site’s mode before they read or write any cookie, so a site switched to cookieless stops using cookies without changing its snippet:

GET https://track.example.com/e?site=st_abcdefghijklmnopqrst

The request goes to the ingest endpoint (data-api if set, otherwise /e on the script’s origin) with credentials: 'omit', so no cookie is sent. The edge answers:

Status Body Headers
200 {"cookieless": true} or {"cookieless": false} Cache-Control: public, max-age=300, Access-Control-Allow-Origin: *, Cross-Origin-Resource-Policy: cross-origin
404 {"error": "unknown_site"} Cache-Control: no-store, same CORS headers

What the tracker does with the answer:

  • cookieless: true: it expires amb_vid, amb_fs, amb_sn and amb_sid on the cookie domain (data-domain or the detected root domain), then boots exactly like the cookieless build: no cookie, no sessionStorage, cl: 1 on every event, no cross-domain handoff.
  • cookieless: false, a 404, any other error, a network failure or no answer within 3 seconds: it boots normally with cookies.

While the check runs, window.amable is a queue: calls made in the meantime (including those already in the pre-load amable.q) are replayed in order once the tracker boots. The check is skipped, and the build boots directly with cookies, when data-site is missing, the browser has no fetch, the browser opted out, or it looks automated. The cookieless build never makes this request.

The edge reads the site settings from a cache refreshed every minute, and browsers may cache the answer for 5 minutes, so a change of the Cookieless switch reaches every visitor within a few minutes. Independently, the edge computes the cookieless visitor id for every event of a cookieless site, even if a browser still sends cookie ids.

With data-cross-domain="shop.example.net,example.org", clicking a link to one of those hosts (or a subdomain) appends five parameters to the link:

Parameter Value
_amb_vid Visitor id
_amb_sid Session id
_amb_fs First-seen time
_amb_sn Session number
_amb_ts Time of the click (ms)

The tracker on the destination page adopts these ids when _amb_ts is less than 10 minutes old (so copied or shared links do not merge strangers), writes them to its own cookies, and removes the parameters from the address bar with history.replaceState. Use the same site id on both domains and list both hostnames in the site, otherwise the destination’s events are refused or counted on another site.

Read once, on the landing page:

Parameter Meaning What the tracker does
_amb_c Signed contact identity added by email click tracking Sends it as ct with the first pageview (the edge verifies the signature and links the visitor to the CRM contact), then removes it from the URL.
he A plain email address or its SHA-256 hex, both lower-cased Sends it in la.he with the first pageview and removes it from the URL. A plain email also triggers an identify with that email.
sl Custom source name (up to 128 characters) Sends it in la.sl; the session gets the source @<name>.
el Email source label (up to 128 characters) Sends it in la.el; the session goes to the Email channel with source @<label>.

See Email links.

On every event, the tracker reads the current URL and sends:

  • Click ids in clk: gclid, fbclid, msclkid, ttclid, twclid, li_fat_id, wbraid, gbraid.
  • Source parameters in src: utm_source, utm_medium, utm_campaign, utm_term, utm_content, ref, source, via.

Values are sanitized (control characters and angle brackets removed, trimmed, at most 255 characters).

Pages reached through funnel tracking links carry a funnel context:

  • When the landing URL has an f parameter (funnel id) or a well-formed vid (funnel visitor id), the tracker stores f, ts (traffic source), n (node), p (page) and vid for the visit and sends them as dl with every event. A vid without f refines the stored context. Generic ?p= or ?n= parameters alone are ignored.
  • Action links are anchors whose path ends with /a/<number>, or anchors with the data-amb-action attribute. The tracker appends vid (funnel visitor id, or the amb_vid cookie) and rn (the current node) to them, so the edge knows where the click came from without cookies. Links added later are decorated too (the tracker watches the page for new links and href changes). Parameters already present are left alone.
  • When the edge receives a pageview with a funnel vid, it links the tracker visitor to the funnel visitor, so the page’s goals, identities and payments join the same journey. A direct-link landing (f and ts in the URL, no vid) records the funnel entrance on the edge.
Event When
pageview At boot; after history.pushState; on popstate; on hashchange in the hash build. The same URL within 60 seconds is sent once (routers often fire twice). history.replaceState is not tracked.
identify When a visitor leaves or changes an email or phone field, and on form submit (unless data-no-forms). Sent only when a value not seen before on the page appears, with the latest email and phone known.
external_link On a click on a link to another host that is not in data-cross-domain (unless data-no-external-links). data.url is the target.
goal On a click on an element (or inside an element) with data-amable-goal; when an element with data-amable-scroll becomes visible.

Form capture rules. Only <input> elements of type text, email or tel are read. A field is an email when its type is email, its autocomplete starts with email, or its name, id or autocomplete contains mail; it is a phone when its type is tel, its autocomplete starts with tel, or the hints contain phone, mobile, cellul, telef, whatsapp, tel or cell. Fields whose name, id or autocomplete contains pass, pwd, card, cc-, cvc, cvv, iban, secret, otp or one-time are never read, and neither is anything inside an element with data-amb-ignore. Emails are lower-cased and validated (up to 254 characters); phones are normalized to digits with an optional + (00 becomes +, 6 to 15 digits).

Attribute On Effect
data-amable-goal="signup_click" Any element A click on it (or on anything inside it) sends the goal.
data-amable-goal-<param>="value" The same element Adds a goal parameter (data-amable-goal-plan="pro" sends plan: "pro"). Also used by scroll goals.
data-amable-scroll="pricing_seen" Any element Sends the goal when the element is visible enough, once per page load.
data-amable-scroll-threshold="0.5" The same element Visible share needed, 0 to 1 (default 0.5).
data-amable-scroll-delay="1000" The same element Milliseconds it must stay visible (default 0).
data-amb-action <a> Treat the link as a funnel action link.
data-amb-ignore Any container Form fields inside it are never captured.

Goal names are normalized: lower-cased, spaces and dashes become _, only a-z, 0-9 and _ are kept, at most 64 characters. Parameters: at most 10 per goal, keys normalized like names, values converted to strings of at most 255 characters; null, undefined and objects are skipped.

The tracker installs window.amable(command, …args), and window.amb as an alias when that name is free.

Command Arguments Sends
amable('pageview') none A pageview of the current URL (subject to the 60-second dedupe).
amable('goal', name, params?) goal name; optional object of up to 10 parameters goal with name and data.
amable('identify', traits) object: user_id, email, name, phone and other traits identify. The edge needs at least user_id, email or phone.
amable('payment', data) object: amount (major units, for example 49.90), currency (ISO 4217), transaction_id (required), optional email, customer_id, renewal, refunded, is_free_trial payment. Converted to minor units on the edge with the currency’s decimals.
amable('conversion', data) object: value (major units, not negative), currency (3 letters), tx (transaction id) goal named conversion with data: { value, currency, tx }. A malformed object is ignored.
amable('context', ctx) object with f, ts, n, p, vid (each 1-64 characters of letters, digits, _ or -) Nothing; merges into the funnel context sent with later events, and re-decorates action links.
amable('optout') none Nothing; sets localStorage.amable_ignore = "true". Tracking stops from the next page load.
amable('optin') none Nothing; removes the opt-out flag.

Unknown commands are ignored. Parameters of identify and payment go through the same sanitizing as goal parameters (at most 10 keys, string values), and the call is ignored when nothing valid remains.

<button data-amable-goal="demo_request" data-amable-goal-plan="pro">Book a demo</button>
<script>
amable('identify', { user_id: 'u_8841', email: 'ada@example.com', name: 'Ada Lovelace' });
amable('goal', 'trial_started', { plan: 'pro', seats: 5 });
amable('payment', { amount: 49.9, currency: 'EUR', transaction_id: 'ord_10045' });
amable('conversion', { value: 49.9, currency: 'EUR', tx: 'ord_10045' });
</script>
  • Each event is sent on its own, immediately: there is no batching and no retry queue in the browser.
  • The tracker uses navigator.sendBeacon(endpoint, body) when available, so events survive page unloads. If the beacon is refused or unavailable, it falls back to fetch with method: POST, keepalive: true, credentials: 'omit' and Content-Type: text/plain.
  • The body is JSON sent as text/plain, which keeps the request “CORS-simple” (no preflight). The edge also answers OPTIONS /e preflights with 204.
{
"type": "pageview",
"site": "st_abcdefghijklmnopqrst",
"url": "https://www.example.com/pricing?utm_source=newsletter",
"ref": "https://www.google.com/",
"vw": 1440, "vh": 900, "sw": 1512, "sh": 982,
"lang": "it-IT",
"tz": "Europe/Rome",
"vid": "6f1c2e8a-4b7d-4f0e-9a51-3c2d1e0f9b87",
"sid": "s3e9a1c0b7d4f2e6a8c5b1d0e9f7a3c2b",
"fs": 1729000000000,
"sn": 3,
"src": { "utm_source": "newsletter" },
"dl": { "f": "fn_01", "ts": "src_02", "n": "node_3", "p": "page_1", "vid": "fv_8c1d2e3f" }
}
Field Type Sent Server limit
type pageview, goal, identify, payment, external_link always required
site string always 1-64 characters, required
url string always; hash removed except in the hash build 1-2,048 characters, required
ref string when document.referrer is set 2,048
vw, vh, sw, sh integers always: viewport and screen size 0-100,000
lang string navigator.language 35
tz string the browser’s IANA time zone 64
vid, sid strings cookie builds 8-64 characters of letters, digits and -
fs integer cookie builds: first-seen time (ms) not negative
sn integer cookie builds: session number 1-1,000,000
cl 1 cookieless build
clk object when click ids are in the URL up to 8 keys, values up to 255
src object when source parameters are in the URL up to 8 keys, values up to 255
name string goals 64; the edge requires a-z, 0-9, _
data object goal parameters, identify traits, payment fields, external link target up to 20 keys; values strings up to 1,024, numbers or booleans
ct string first pageview with _amb_c 4,096
dl object every event once a funnel context is known f, ts, n, p, vid, each 1-64 characters; invalid objects are dropped
la object first pageview with he, sl or el he 320, sl and el 128; invalid objects are dropped

Unknown keys are dropped. The body may be at most 16 KB.

What the edge does with each event:

  1. Checks the size and the schema, and loads the site.
  2. Checks the origin: the host of the Origin header (or of the Referer when there is no origin) and the host of url must both be one of the site’s hostnames or a subdomain of one. Local hosts are accepted only when the site allows localhost.
  3. Detects bots from the user agent (known AI assistants, training crawlers, search indexers, generic bots, empty user agents). Bot hits are counted separately with their name, provider, category (ai_answers, training, indexing, other) and an IP verification against the provider’s published ranges (verified, spoofed, unknown); they never become visitors.
  4. Enriches the event (geo from the request, device, browser and OS, channel), computes the cookieless visitor id when needed, validates the goal name, the payment (amount not negative, 3-letter currency, transaction_id present) or the identity (user_id, email or phone), and queues it for the site’s storage.
Answer Body Meaning
202 { "ok": true } Accepted (bots too).
400 { "error": "invalid_event" } Schema error, unusable URL, invalid goal name, payment or identity.
403 { "error": "origin_not_allowed" } The page or origin host is not one of the site’s hostnames.
404 { "error": "unknown_site" } No site with that id.
413 { "error": "payload_too_large" } Body over 16 KB.

Answers echo the request Origin in Access-Control-Allow-Origin. Because the tracker uses beacons, these answers are not visible in the page: use the browser’s network panel, or the site’s install check (GET /analytics/sites/{siteId}/install-check, which reports the last event and the number of events in the last 24 hours).

Backends can send events that never run in a browser (a payment confirmed by your payment provider, a signup completed on your server, AI crawlers hitting pages that do not run JavaScript).

POST /e/server on the edge origin, authenticated with the site’s server secret:

Terminal window
curl -X POST "https://track.example.com/e/server" \
-H "Authorization: Bearer amb_sk_st_abcdefghijklmnopqrst.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '{
"type": "payment",
"visitor_id": "6f1c2e8a-4b7d-4f0e-9a51-3c2d1e0f9b87",
"amount": 49.9,
"currency": "EUR",
"transaction_id": "ord_10045",
"email": "ada@example.com"
}'

The secret looks like amb_sk_<site id>.<40 characters>. It is shown once when the site is created; replace it with Roll secret on the site in the analytics settings, or with POST /analytics/sites/{siteId}/secret. The previous secret stops working right away (the edge may still accept it for up to 60 seconds while its cache refreshes). Body types:

type Fields
goal visitor_id (required), name (required, a-z 0-9 _, up to 64), url, params (up to 10 keys; strings up to 255, numbers, booleans)
payment amount (major units, not negative, required), currency (ISO 4217, required), transaction_id (1-255, required), visitor_id, email, customer_id, renewal, refunded, is_free_trial. Without visitor_id the payment is attributed by email.
identify visitor_id (required), user_id (required), email, name, traits (up to 10 keys)
pageview url (required), user_agent (required), ip (required), referrer, visitor_id. A bot user agent is recorded as a bot hit.
crawler url (required), user_agent (required), ip. Records a bot hit when the user agent is a bot; otherwise nothing.

visitor_id is the amb_vid cookie of the visitor (read it in your backend from the request, or pass it from the page). Answers: 202 { "ok": true } (for pageview and crawler also "bot": the detected bot with its verification, or null), 400 invalid_event with up to 5 details (path, message), 401 invalid_site_secret, 413 payload_too_large.

Ready-made Worker, Node and PHP snippets that report AI crawlers to /e/server are available from GET /analytics/sites/{siteId}/crawler-snippets.

Site-key analytics API, as an alternative for goals, identities and payments: POST /api/v2/analytics/goals, /identify and /payments on your dashboard host, with a site key that has the write scope (Authorization: Bearer amb_ak_<site id>.<secret>). The bodies are the same as above without type (goals: visitor_id, name, params; identify: visitor_id, user_id, email, name; payments: visitor_id, amount, currency, transaction_id, email, renewal, refunded). Answers 202 { "ok": true }. See REST API.

  1. Create a site in the analytics settings (Sites tab), with the hostnames that will send events. Copy the snippet.

  2. Paste the snippet in the <head> of every page.

  3. Open your site and check the network panel: a POST to /e answering 202.

  4. Check the Installation status on the Tracking tab of the analytics settings (last event received and events in the last 24 hours).

  1. Choose a goal name: lower case, digits and _ (for example newsletter_signup).

  2. Either add data-amable-goal="newsletter_signup" to the button, or call amable('goal', 'newsletter_signup', { list: 'weekly' }) from your code.

  3. Goals need no configuration: the name appears in the goal reports as soon as the first completion arrives, and you can use it in funnels and goal alerts. See Goals and funnels.

  1. On the thank-you page, call amable('payment', { amount, currency, transaction_id }) with the order id as transaction_id.

  2. From your backend, after the payment provider confirms, send the same payment to POST /e/server with the same transaction_id and the visitor’s amb_vid as visitor_id.

  3. Use the same transaction_id everywhere (including CRM orders and funnel postbacks), so one sale is never counted twice.

  1. Add both hostnames to the site.

  2. On each domain, add data-cross-domain with the other domain to the script tag, for example data-cross-domain="shop.example.net" on www.example.com.

  3. Click a link from one domain to the other and check that the address bar of the destination briefly showed _amb_vid and that the same visitor appears in the visitor profile.

  1. Connect a custom tracking domain to the site (for example track.example.com). See Tracking domains.

  2. Load the script from it: src="https://track.example.com/s.js". The tracker sends events to /e on the same origin as the script, so no data-api is needed.

  3. Use data-api only when events must go to a different endpoint than the script’s origin.

The tracker source exposes, for embedding and tests, the constants that define the protocol: cookie names (amb_vid, amb_sid, amb_fs, amb_sn), lifetimes (365 days, 30 minutes), the handoff parameters and their 10-minute validity, the click id and source parameter lists, the contact token parameter (_amb_c), the direct-link parameters (f, ts, n, p), the action link attribute (data-amb-action), the conversion goal name (conversion), the pageview dedupe window (60 seconds), the goal limits (10 parameters, 255-character values, 64-character names) and the opt-out key (amable_ignore).

Method and path Purpose
GET /s.js, /s.cookieless.js, /s.hash.js Tracker scripts
GET /e?site=<site id> Site mode check of the cookie builds: {"cookieless": true} or {"cookieless": false}, or 404 unknown_site
POST /e Browser events
OPTIONS /e Preflight
POST /e/server Server events (site secret)
GET /a/<n> Funnel action links (decorated by the tracker). See Tracking links.

Other public edge routes (tracking links, postbacks, email links, hosted forms and pages) are listed in Tracking endpoints.

Item Limit
Event body 16 KB
Goal name 64 characters, a-z 0-9 _
Goal parameters 10 from the tracker (20 data keys accepted by the edge)
Parameter value 255 characters from the tracker (1,024 accepted by the edge)
URL, referrer 2,048 characters
Pageview dedupe same URL within 60 seconds
Session timeout 30 minutes without events
Cross-domain handoff validity 10 minutes
Site hostnames 1 to 20 per site, each also covering its subdomains

Getting the snippet needs analytics:read; creating sites, rolling the server secret and creating site keys need analytics:configure. The tracker and /e need no credential; /e/server needs the site’s server secret.

Symptom Cause Fix
No POST to /e at all The tracker is off: no data-site, opted out, bot detection (automated browser), iframe, or localhost Check the attribute; remove localStorage.amable_ignore; add data-allow-iframe or data-allow-localhost (and allow localhost on the site) when needed.
/e answers 403 origin_not_allowed The page host is not one of the site’s hostnames Add the hostname (subdomains are covered automatically).
/e answers 404 unknown_site Wrong data-site, or the site was deleted Copy the snippet again.
/e answers 400 invalid_event for payments transaction_id missing, currency not 3 letters, or a negative amount Fix the amable('payment', …) call.
Goals do not appear The name contains characters outside a-z 0-9 _ after normalization, or the goal is not configured in the site Use a simple name and configure the goal.
Each visit looks like a new visitor Cookieless mode (the cookieless build, or a site with Cookieless switched on, which makes /s.js and /s.hash.js cookieless too), or the cookie domain is wrong Switch Cookieless off for the site and use /s.js; set data-domain to your root domain.
GET /e?site=… answers 404 unknown_site Wrong data-site, or the site was deleted Copy the snippet again; meanwhile the tracker falls back to cookies and its events are refused.
amb_ cookies are still set on a cookieless site The mode answer is cached for up to 5 minutes, and the edge refreshes site settings every minute Wait a few minutes; the next page load expires the cookies.
Visitors are split across your domains Cross-domain linking not configured Add data-cross-domain on both sides and both hostnames to the site.
Duplicate pageviews in a single-page app Two different URLs are pushed for the same screen Push the final URL once; same-URL repeats within 60 seconds are already dropped.
/e/server answers 401 invalid_site_secret Wrong, old or malformed secret Roll the secret and update your backend (the old one stops within 60 seconds).