Events
The Kelp event taxonomy - every named event kind, its tracker method, and the full event field reference.
Kelp defines a closed set of named ecommerce event kinds. Each client-emitted kind has a matching method on the createAnalytics tracker that composes the event with its kind and auto-fills ambient fields.
Event taxonomy
Session
| Method | Event kind | When to emit |
|---|---|---|
startSession(input?) | session_started | A new session began. Captures landing context and emits at most once per session. |
trackSessionStarted(input?) | session_started | Emit session_started directly - no capture and no dedupe. |
analytics.startSession({ collection: 'products' });startSession is safe to call on every page load. It requires an attribution store on createAnalytics; without one it is a no-op. Prefer it over trackSessionStarted unless you need to emit without capture or dedupe.
Search and browse
| Method | Event kind | When to emit |
|---|---|---|
trackSearch(input) | search | A search or browse query runs and results are returned. |
analytics.trackSearch({
collection: 'products',
q: 'running shoe',
found: res.found,
page: res.page,
queryId: res.queryId,
filters: [{ field: 'status', op: '=', values: ['ACTIVE'] }],
});filters is serialized into the filterBy string automatically using defaultSerializeFilterBy, e.g. status:=[ACTIVE]. Override the format by passing serializeFilterBy to createAnalytics.
Product events
| Method | Event kind | When to emit |
|---|---|---|
trackProductClicked(input) | product_clicked | A visitor clicks a product result or suggestion. Pass queryId to attribute the click to the originating search. |
trackProductViewed(input) | product_viewed | A product detail page (PDP) is viewed. |
trackProductWishlisted(input) | product_wishlisted | A product is saved to a wishlist or favourites. |
trackProductAddedToCart(input) | product_added_to_cart | A product is added to the cart. Pass queryId to attribute to the originating search. |
analytics.trackProductClicked({
collection: 'products',
objectId: '9149995942110',
queryId: res.queryId,
});
analytics.trackProductViewed({ collection: 'products', objectId: '9149995942110' });
analytics.trackProductWishlisted({ collection: 'products', objectId: '9149995942110' });
analytics.trackProductAddedToCart({
collection: 'products',
objectId: '9149995942110',
queryId: res.queryId,
});objectId is the product's id in your collection (Shopify product id on view, click, wishlist, cart, and purchase line items). Collection views use the collection id or handle.
Collection events
| Method | Event kind | When to emit |
|---|---|---|
trackCollectionViewed(input) | collection_viewed | A collection or category page is viewed. |
analytics.trackCollectionViewed({
collection: 'products',
objectId: 'summer-sale', // the collection handle (e.g. 'mens-shoes', 'all'), not a product id
queryId: res.queryId,
});Purchase
| Method | Event kind | When to emit |
|---|---|---|
trackPurchase(input) | purchase | An order is completed. |
analytics.trackPurchase({
collection: 'products',
orderId: 'order-1001',
value: 129.99,
currency: 'USD',
items: [
{ objectId: '9149995942110', quantity: 1, price: 129.99 },
{ objectId: '9149995942111', quantity: 2, price: 49.99 },
],
// queryId is intentionally omitted on purchase in most integrations.
// See note below.
});items[].objectId is the product numeric id (the GID tail: String(gid).split('/').pop()), not the variant id or handle.
Purchase value, currency, orderId, and items are first-class persisted fields - send them on the event, not inside metadata.
queryId on purchase events: queryId is optional and typically omitted for purchase events on multi-page storefronts. A real-world cart often contains items added after different searches - attaching any single queryId would misattribute the conversion. Purchase attribution to a search session works via sessionId and userId instead, which are stable across the session. See Attribution for details.
In Shopify Hydrogen, the purchase event is sent by a custom pixel (not the storefront SDK) because the storefront JavaScript does not run during checkout. The pixel reads sessionId and userId from cart attributes stamped server-side before the checkout redirect. queryId is stamped as a cart attribute but deliberately not forwarded by the pixel.
Email events
Email events are emitted by createKelpEmail - you do not call these on the analytics tracker. See Email capture.
Event kind | Emitted by | When |
|---|---|---|
email_subscribed | email.subscribe(...) | Contact opted in. |
email_unsubscribed | email.unsubscribe(...) | Contact opted out. |
email_opened | reserved | An email was opened. Not emitted by the client yet. |
email_clicked | reserved | A link in an email was clicked. Not emitted by the client yet. |
Email kinds carry a nested Email object (see field reference below). There is no flat root email / source / listId shape.
track()
Use track() only for a named kind that has no helper. kind must be one of the kinds above. The SDK does not accept custom strings. Ambient fields (occurredAt, sessionId, userId) are still auto-filled.
Low-level: trackEvents
kelp.trackEvents(events) is the raw transport. You supply fully-formed events - no auto-filling. kind must be a named KelpEventKind. Use this only when createAnalytics is not suitable (e.g. server-side ingestion from your own backend).
await kelp.trackEvents([
{
kind: 'search',
occurredAt: '2026-08-03T12:00:00Z',
collection: 'products',
sessionId: 'sess-1',
userId: 'anon_1a3b',
q: 'shoes',
found: 12,
page: 1,
queryId: '019f7571-998f-7bb5-abdd-0945c5be7a4a',
},
]);The SDK still wraps the array in the batch envelope { id, tenantCode?, events } before posting.
Event field reference
All fields on KelpAnalyticsEvent:
| Field | Required | Type | Notes |
|---|---|---|---|
kind | yes | KelpEventKind | Named event type - see the taxonomy above. Closed set of 12 kinds. |
occurredAt | yes | ISO 8601 string | Event-root only. Auto-filled by createAnalytics. Not on Attribution. |
sessionId | yes | string | Auto-filled by createAnalytics from identity.getSessionId(). |
userId | no | string | Kelp visitor id - identified user, or anon_<stable-id> for anonymous visitors. Not a Shopify customer id. |
collection | no | string | Collection name. Required for search, product, and collection events; optional for email events. |
q | no | string | Query string (search events). |
filterBy | no | string | Serialized filter expression, e.g. brand:=[globex] && price:>0. Set by trackSearch from the filters array. |
found | no | number | Result count (search events). |
page | no | number | Page number (search events). |
queryId | no | string | Ties a click or conversion event back to a search response. See Attribution (queryId chaining). Separate from the UTM Attribution object below. |
objectId | no | string | Subject document id: product id for product events, collection handle/id for collection_viewed. |
email | no | Email | Nested Email DTO (optional on every kind). See below. |
attribution | no | Attribution | Nested Attribution DTO (optional on every kind). See below. |
value | no | number | Order total (purchase). First-class persisted. |
currency | no | string | ISO 4217 currency code, e.g. 'USD' (purchase). First-class persisted. |
orderId | no | string | Order id (purchase). First-class persisted. |
items | no | { objectId, quantity?, price? }[] | Line items (purchase). First-class persisted (flexible JSON). |
metadata | no | object | Optional event-level JSON (KEL-52). Stored as jsonb. An empty object is stored as null. Only objects are valid. Separate from email.meta and attribution.meta. |
Email object
Optional nested object on any event kind. When present, email (the address) is required. source is optional on the Email object (capture point, e.g. 'footer-form'). It is separate from Attribution source, which remains required when Attribution is present.
| Field | Required | Type | Notes |
|---|---|---|---|
email | yes (when object present) | string | Contact address. |
source | no | string | Capture point, e.g. 'footer-form'. Optional; only on object form. |
listId | no | string | Target list id. |
campaignId | no | string | Campaign id (e.g. reserved open/click kinds). |
details | no | EmailDetails | Person fields: name, firstName, lastName, phone. |
meta | no | Record<string, unknown> | Email-scoped overflow JSON. Not event metadata. |
Helpers that accept a flat string address map it to { email } only. source is optional when using the object form.
// Nested Email on subscribe (via createKelpEmail)
email.subscribe({
email: 'shopper@example.com',
source: 'footer-form',
listId: 'list_newsletter',
details: { firstName: 'Sam', lastName: 'Shopper' },
meta: { formId: 'footer-v2' },
});Attribution object
Optional nested object on any event kind (UTM / traffic source). When present, source is required; medium and the rest are optional. occurredAt is not on this object (occurredAt lives on the event root only).
| Field | Required | Type | Notes |
|---|---|---|---|
source | yes (when object present) | string | Traffic source, e.g. 'google'. |
medium | no | string | e.g. 'organic', 'cpc'. |
campaign | no | string | Campaign name. |
content | no | string | Creative / content. |
term | no | string | Paid keyword. |
campaignRef | no | string | External campaign reference. |
clickId | no | string | Click id value. |
clickIdParam | no | string | Param name that held the click id. |
referrer | no | string | Document referrer. |
landingPage | no | string | Landing path. |
meta | no | Record<string, unknown> | Attribution-scoped overflow JSON. Not event metadata. |
{
kind: 'session_started',
occurredAt: '2026-09-17T12:04:30.000Z',
sessionId: 'sess_01HZY',
userId: 'anon_01HZY',
attribution: {
source: 'google',
medium: 'organic',
referrer: 'https://www.google.com/',
landingPage: '/',
meta: { gclid: 'example' },
},
}Search-to-conversion chaining with queryId is documented separately in Attribution. That guide is about threading queryId, not this UTM Attribution object.
Purchase scalars (value, currency, orderId, items) and typed email / attribution are first-class persisted fields (KEL-57). Do not dump them into event metadata. Use metadata for other open JSON; use email.meta / attribution.meta for overflow scoped to those objects.
Related
- Analytics overview - pipeline, batching, and
createAnalyticsoptions - Attribution - search-to-conversion attribution with
queryId - Email capture - email events and the shared pipeline