The Tracking API is a dedicated, low-latency ingestion service that runs on its own host, separate from the main Layers Storefront API. It’s optimized for being called from the browser usingDocumentation Index
Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt
Use this file to discover all available pages before exploring further.
navigator.sendBeacon or fetch with keepalive, so events keep flowing even as shoppers navigate between pages.
Why a separate API?
The Tracking API is split out from the main API Reference for three reasons:- Different host. Events ship to
https://cl.uselayers.com/beacon, nothttps://app.uselayers.com/api/storefront/v1. The collection endpoint is deployed globally as a Cloudflare Worker for minimum write latency from any region. - Different auth model. The Tracking API accepts the storefront token either as the
X-Storefront-Access-Tokenheader or as a?token=query parameter. Query‑parameter auth exists specifically sonavigator.sendBeaconcalls — which can’t set custom headers — still authenticate correctly. - Different response contract. Successful writes return
201with an empty body. Events are validated and dispatched asynchronously; invalid events inside a batch are dropped silently so one bad event doesn’t fail the whole batch.
Base URL
POST /beacon.
When to call it directly
Most stores don’t need to. If you use the Storefront Pixel or the Layers JavaScript SDK, tracking is wired up automatically and you can skip this section. Call the Tracking API directly when you’re:- Building a custom storefront (headless, Hydrogen, Next.js Commerce) where the pixel isn’t loaded.
- Instrumenting a mobile app or native shopping channel.
- Backfilling events from a server-side process or third-party tag manager.
Next steps
- Authentication — how to pass the storefront token.
- Send events — the full
POST /beaconreference. - Event types — payload schemas for every supported event.
- Sending events with
navigator.sendBeacon— recommended browser pattern.