Events / analytics

Post search and conversion events to Kelp in batches, with queryId attribution.

Search and conversion events flow through a single batched endpoint.

POST https://{TENANT_ID}-events.kelp.click/analytics/events

Headers: Content-Type: application/json and X-Api-Key: <key>.

Request envelope

The body is a batch envelope: a unique batch id (UUID v4), an optional tenantCode, and an array of events.

{
  "id": "3f9a7c2e-1b6d-4e9a-9c11-8f2a5d0b7e42",
  "tenantCode": "acme",
  "events": [
    {
      "kind": "search",
      "collection": "products",
      "sessionId": "s_a1b2c3",
      "userId": "u_42",
      "occurredAt": "2026-01-01T12:00:00.000Z",
      "queryId": "q_9f3a...",
      "q": "sunglasses"
    }
  ]
}

Event fields

FieldTypeNotes
kindKelpEventKindNamed event type (see below). Required.
collectionstringThe Kelp collection the event belongs to, e.g. products. Required on every kind except session_started and the email_* kinds, where it is optional.
sessionIdstringRolling anonymous session id. Required.
userIdstringKelp visitor id. When anonymous, use anon_<anonymousId>.
occurredAtstringISO 8601 timestamp on the event root only. Required.
qstringThe search term. Required on search events.
filterBystringSerialized filter expression applied to the search, if any. Optional on search.
foundnumberTotal number of results the search returned. Optional on search.
pagenumberResults page number. Optional on search and product events.
objectIdstringThe subject of the event: the product id for product_* events, or the collection handle/id for collection_viewed. Optional single primary product on purchase.
queryIdstringFor post-search events, the queryId from the search response.
emailEmailOptional nested Email DTO (email address required when present; optional source for capture point, e.g. 'footer-form').
attributionAttributionOptional nested Attribution DTO (source required when present; medium optional; no occurredAt on the object - event-root only).
value / currency / orderId / itemsscalars / arrayFirst-class purchase fields - persisted, not metadata-only.
metadataobjectOptional event-level JSON (KEL-52). Stored as jsonb. Separate from email.meta / attribution.meta. An empty object is stored as null. Only objects are valid.

The SDK fills sessionId, userId, and occurredAt automatically from identity. Direct callers must supply them. Additional fields depend on kind - see the full taxonomy, typed Email / Attribution shapes, and persistence notes in Analytics events.

Event kinds

Closed named set of 12: session_started, search, product_viewed, product_clicked, product_wishlisted, product_added_to_cart, collection_viewed, purchase, email_subscribed, email_unsubscribed, email_opened (reserved), email_clicked (reserved).

email_opened and email_clicked are not emitted by the client yet. Subscribe and unsubscribe are events on this same endpoint. See Email capture.

Attribution

To attribute a click or conversion to the search that surfaced it, copy the queryId from the search response onto the later event:

{
  "id": "b7c1...-uuid",
  "events": [
    { "kind": "product_clicked", "sessionId": "s_a1b2c3", "occurredAt": "2026-01-01T12:00:05.000Z", "queryId": "q_9f3a...", "objectId": "1" }
  ]
}

See Attribution for the full queryId funnel. That guide is separate from the optional UTM Attribution object (source / medium / ...) documented on Analytics events.

A successful batch returns a 2xx with no meaningful body. Send events in batches rather than one request per event, and generate a fresh id per batch.

On this page