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/eventsHeaders: 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
| Field | Type | Notes |
|---|---|---|
kind | KelpEventKind | Named event type (see below). Required. |
collection | string | The Kelp collection the event belongs to, e.g. products. Required on every kind except session_started and the email_* kinds, where it is optional. |
sessionId | string | Rolling anonymous session id. Required. |
userId | string | Kelp visitor id. When anonymous, use anon_<anonymousId>. |
occurredAt | string | ISO 8601 timestamp on the event root only. Required. |
q | string | The search term. Required on search events. |
filterBy | string | Serialized filter expression applied to the search, if any. Optional on search. |
found | number | Total number of results the search returned. Optional on search. |
page | number | Results page number. Optional on search and product events. |
objectId | string | The subject of the event: the product id for product_* events, or the collection handle/id for collection_viewed. Optional single primary product on purchase. |
queryId | string | For post-search events, the queryId from the search response. |
email | Email | Optional nested Email DTO (email address required when present; optional source for capture point, e.g. 'footer-form'). |
attribution | Attribution | Optional nested Attribution DTO (source required when present; medium optional; no occurredAt on the object - event-root only). |
value / currency / orderId / items | scalars / array | First-class purchase fields - persisted, not metadata-only. |
metadata | object | Optional 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.