SDK API
Reference the public Cevoid Analytics SDK methods for initialization, tracking, identity, and resets.
Use this page when you already know you need the Cevoid Analytics SDK and want the exact public method surface. If you are still deciding between automatic widget behavior, browser-event forwarding, or manual tracking, start with Overview.
Public SDK payload fields use camelCase. The SDK normalizes them to the internal snake_case telemetry format before sending events to the backend.
init(config)
Initializes the SDK. Call it once before your first tracking method. Repeated calls after the first successful initialization are ignored.
| Option | Type | Default | Description |
|---|---|---|---|
publishableKey | string | None | Required workspace publishable key. |
enableSessionTracking | boolean | false | Enables Cevoid-managed session tracking after consent checks pass. |
requireConsent | boolean | false | Sends no events until tracking consent is granted. Consent that no consent tool has answered counts as denied. Browser events still fire. See Consent. |
cookieDomain | string | None | Sets the domain for the ca_session cookie. |
emitBrowserEvents | boolean | true | Emits browser CustomEvents such as cevoid:post.click. |
apiHost | string | https://telemetry.cevoid.com | Overrides the telemetry host. |
If enableSessionTracking or requireConsent is true, tracked events are deferred until consent resolution completes, at most 100 of them (the oldest are dropped first).
trackEvent(name, data)
Tracks a supported Cevoid UGC widget event.
import { trackEvent } from '@cevoid/analytics-sdk'
trackEvent('post.click', {
widgetId: 'gallery-homepage',
postId: 'post_123',
postPosition: 4,
taggedProductIds: ['prod_1', 'prod_2']
})Use trackEvent() for custom storefront implementations that need to send supported Cevoid event names manually. The SDK sets widgetType to api on every trackEvent() call, so you do not pass it.
Supported event names:
widget.loadwidget.viewpost.viewpost.clickpost.view.popuppost.clapproduct.click.tagproduct.click.postproduct.click.cardgallery.load_moregallery.upload_cta_click
Unknown event names are ignored.
trackSale(data)
Tracks a completed storefront purchase as sale.complete.
Use this for manual storefront implementations. Standard Shopify sales tracking uses the checkout web pixel path instead of calling trackSale().
import { trackSale } from '@cevoid/analytics-sdk'
trackSale({
orderId: 'order_123',
marketId: 'market_123',
customerId: 'cust_456',
currency: 'USD',
revenue: 129.99,
skus: ['SKU-1', 'SKU-2']
})Required fields:
orderIdcurrencyrevenue
Optional fields:
marketIdcustomerIdskus
Use trackSale() for completed purchases, not trackEvent() with sale.complete.
identify(data)
Deprecated since 1.2.0. It sends nothing: no event carries external_id. Existing calls keep working, so you can remove them at your own pace. It will be removed in 2.0.0.
reset()
Clears SDK initialization state, deferred events, and in-memory identity data.
import { reset } from '@cevoid/analytics-sdk'
reset()Use this on hard storefront context changes such as logout flows when you need to clear the current client-side analytics state.