> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cevoid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/developer-docs/analytics).

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`  | —                              | Required workspace publishable key.                                                                                     |
| `enableSessionTracking` | `boolean` | `false`                        | Enables Cevoid-managed session tracking after consent checks pass.                                                      |
| `cookieDomain`          | `string`  | —                              | Sets the domain for the `ca_session` cookie.                                                                            |
| `emitBrowserEvents`     | `boolean` | `true`                         | Emits browser [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)s 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.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { trackEvent } from '@cevoid/analytics-sdk'

trackEvent('post.click', {
  widgetId: 'gallery-homepage',
  widgetType: 'gallery',
  postId: 'post_123',
  postPosition: 4,
  taggedProductIds: ['prod_1', 'prod_2']
})
```

Use [`trackEvent()`](/developer-docs/analytics-sdk/api#trackeventname-data) for custom storefront implementations that need to send supported Cevoid event names manually.

Supported event names:

* [`widget.load`](/developer-docs/analytics-sdk/events/widget-load)
* [`widget.view`](/developer-docs/analytics-sdk/events/widget-view)
* [`post.view`](/developer-docs/analytics-sdk/events/post-view)
* [`post.click`](/developer-docs/analytics-sdk/events/post-click)
* [`post.view.popup`](/developer-docs/analytics-sdk/events/post-view-popup)
* [`post.clap`](/developer-docs/analytics-sdk/events/post-clap)
* [`product.click.tag`](/developer-docs/analytics-sdk/events/product-click-tag)
* [`product.click.post`](/developer-docs/analytics-sdk/events/product-click-post)
* [`product.click.card`](/developer-docs/analytics-sdk/events/product-click-card)
* [`gallery.load_more`](/developer-docs/analytics-sdk/events/gallery-load-more)
* [`gallery.upload_cta_click`](/developer-docs/analytics-sdk/events/gallery-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()`](/developer-docs/analytics-sdk/api#tracksaledata).

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

* `orderId`
* `currency`
* `revenue`

Optional fields:

* `marketId`
* `customerId`
* `skus`

Use [`trackSale()`](/developer-docs/analytics-sdk/api#tracksaledata) for completed purchases, not [`trackEvent()`](/developer-docs/analytics-sdk/api#trackeventname-data) with `sale.complete`.

## `identify(data)`

Attaches profile-level context to future events.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { identify } from '@cevoid/analytics-sdk'

identify({
  profileId: 'profile_123',
  externalId: 'shopify_customer_456'
})
```

Supported fields:

* `profileId?: string`
* `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.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
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.

## Related

* [Installation](./installation)
* [Event Types](./events/index)
* [Manual Event Tracking](/developer-docs/analytics/track-events)
* [Track Sales](/developer-docs/analytics/track-sales)
