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.

Every event in a POST /beacon batch is validated against a schema chosen by its event_type field. Events that don’t match their schema are dropped from the batch.

Common fields

These fields are accepted on every event. Server-enriched fields (geo, device, browser, OS) are added automatically — don’t send them.
event_id
string
required
Unique identifier for the event. Use a ULID or UUID generated client-side. Required for deduplication.
event_type
string
required
The event discriminator. Must be one of the values listed in Supported event types.
timestamp
string
required
ISO 8601 timestamp of when the event occurred (e.g., "2026-06-01T14:30:00Z"). Accepted as either an ISO string or a Date-parseable value; stored in UTC.
session_id
string
required
Anonymized session identifier for the shopper’s visit. Should be stable for the duration of a session and rotate at session expiry.
customer_id
string
Logged-in customer identifier. null or omitted for guests.
attribution_token
string
The token returned by Search, Browse, or Blocks. Required to attribute downstream product_click, product_view, add_to_cart, and block_view events back to the originating request.
shopping_channel
string
"web" or "app". Optional. If omitted, the worker infers it from User-Agent and the X-Requested-With header.
product_id
number
Shopify product ID. Required for product-scoped events (see below).
variant_id
number
Shopify variant ID.
collection_handle
string
Collection handle. Required for collection_view.
position
number
1-indexed position in the result set. Required for product_click, product_impression, product_hover, product_touch.
marketing_source
string
UTM source.
marketing_medium
string
UTM medium.
marketing_campaign
string
UTM campaign.
contextual_data
object
Free-form additional context (e.g., A/B test bucket, page template, locale). Defaults to {}.

Server-enriched fields

Don’t set these — the worker fills them in:
FieldSource
geo_countryCloudflare edge (cf.country)
geo_stateCloudflare edge (cf.regionCode)
geo_cityCloudflare edge (cf.city), lowercased
device_typeParsed from User-Agent
browserParsed from User-Agent
osParsed from User-Agent
shopping_channelInferred from User-Agent and X-Requested-With if not supplied

Supported event types

Engagement events (fired from the storefront):
event_typeAdditional required fieldsDescription
collection_viewcollection_handleShopper viewed a collection page.
product_viewproduct_idShopper viewed a product detail page.
product_clickproduct_id, positionShopper clicked a product in a result list.
product_impressionproduct_id, positionA product tile entered the viewport.
product_hoverproduct_id, positionDesktop hover on a product tile.
product_touchproduct_id, positionMobile tap or long-press on a product tile.
add_to_cartproduct_id, variant_idShopper added a variant to cart.
searchsearch_queryA text search was executed.
autocompletesearch_queryAn autocomplete query was issued.
block_viewblock_idA block recommendation widget became visible.
Request events (typically sent server-side by the platform, not the storefront — included here for completeness):
event_typeRequired fieldsDescription
search_requestA text/image/similar search request was served.
browse_requestcollection_handleA collection browse request was served.
block_requestblock_id, anchor_type, strategy_type, num_results, current_page, per_pageA block request was served.
Storefront integrations should generally only send the engagement events in the first table. The request events are emitted by the Layers platform itself.

Validation rules

  • event_id, event_type, timestamp, session_id are required on every event.
  • event_type must be one of the values above. Unknown types are dropped.
  • Type-specific required fields above must be present; missing them causes the individual event to be dropped (the batch still ingests).
  • The batch must contain between 1 and 100 events. Outside that range, the entire request fails with 422.

Next steps