Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt

Use this file to discover all available pages before exploring further.

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 using 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, not https://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-Token header or as a ?token= query parameter. Query‑parameter auth exists specifically so navigator.sendBeacon calls — which can’t set custom headers — still authenticate correctly.
  • Different response contract. Successful writes return 201 with 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

https://cl.uselayers.com
There’s only one endpoint today: 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