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

# SDK reference

> Explore the analytics SDK methods.

## Extension

| Method | Purpose |
| - | - |
| `analytics.init(config)` | Initialize analytics in the background. |
| `analytics.track(name, properties?)` | Record a custom event. |
| `analytics.view(name?)` | Record an extension view, with an optional custom name. |
| `analytics.identify(id)` | Set an account identifier for future events. |
| `analytics.clearIdentity()` | Clear the identifier for future events. |

## Website

| Method | Purpose |
| - | - |
| `analytics.init(config)` | Initialize analytics on your website. |
| `analytics.attributeInstall()` | Associate a welcome-page visit with an install's acquisition source. |
| `analytics.recordUninstall()` | Report an observed uninstall from your uninstall page. |

Extension tracking calls resolve when an event is saved for delivery, not when the server receives it. A failed call rejects; handle failures so analytics does not interrupt your extension's main features. `identify()` and `clearIdentity()` resolve when the identity change is saved locally. See [Events](https://docs.crxbase.com/analytics/events.md) for property limits and [Identify users](https://docs.crxbase.com/analytics/identify.md) for identity rules.

## Configuration

Both entry points accept the same project ID. The extension entry point also accepts your welcome page and an optional uninstall page:

```typescript theme={null}
analytics.init({
  projectId: "YOUR_PROJECT_ID",
  welcomeUrl: "https://example.com/extension/welcome",
  uninstallUrl: "https://example.com/extension/goodbye",
});
```

The website entry point uses `analytics.init({ projectId })`. Initialize the extension SDK in the background; its listeners register immediately, and subsequent calls wait for initialization.

## track

`analytics.track(name, properties?)` records an extension custom event. The event name is a string; properties are optional strings or finite numbers. Events carry installation and event context.

```typescript theme={null}
await analytics.track("export_completed", { format: "csv", count: 12 });
```

Avoid event names beginning with `_`, which crxbase uses for platform events. The SDK does not block those names. See [Events and views](https://docs.crxbase.com/analytics/events.md) for property limits.

## view

`analytics.view(name?)` records an extension view. Pass a string to use a custom name; otherwise the SDK detects a common surface when possible and uses `unknown` if it cannot.

```typescript theme={null}
await analytics.view("settings");
```

## identify and clearIdentity

`analytics.identify(id)` sets a nonblank string identifier for future extension events. `analytics.clearIdentity()` clears it for future events. Neither call creates an event or changes earlier events. See [Identify users](https://docs.crxbase.com/analytics/identify.md) for identifier limits and examples.

## attributeInstall

Call `analytics.attributeInstall()` on your website's welcome page after initializing the website SDK. It associates eligible acquisition information with the extension installation. A missing or invalid installation handoff does not create an install or attribution. The method does not return a queued, skipped, or failed status value.

## recordUninstall

Call `analytics.recordUninstall()` on your configured uninstall page after initializing the website SDK. It reports the removal using the installation information supplied to the page. Reporting is optional and best effort.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.