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. |
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 is true, tracked events are deferred until consent resolution completes.
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)
Attaches profile-level context to future events.
import { identify } from '@cevoid/analytics-sdk'
identify({
externalId: 'shopify_customer_456'
})Supported fields:
externalId?: string
This data is stored in SDK memory and attached to future tracked events. Call identify() again to replace the current identity payload.
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.