# Analytics setup

> Install TraceKit browser analytics and verify your first pageview.

- Canonical: https://tracekit.dev/docs/analytics

## Install the SDK

Install `@tracekit/browser` in the application that you want to measure.

```bash
npm install @tracekit/browser
```

Get the Public `ctxio_pub_...` key from [TraceKit API keys](https://app.tracekit.dev/api-keys).
Match `serviceName` to the active TraceKit service.

```ts
import { init } from '@tracekit/browser';

init({
  apiKey: 'ctxio_pub_...',
  serviceName: 'your-service-name',
});
```

Your first pageview appears after TraceKit initializes.

## Verify the first pageview

Visit your application after `init()` runs.
init() records the first pageview automatically.
SPA route changes record later pageviews.

[Open Analytics](https://app.tracekit.dev/analytics)

The query strings and fragments are removed from URLs and referrers.
The allowed origins are optional and comma-separated.
An empty allowed-origin list allows every origin.

If pageviews are missing, confirm the Public key, `serviceName`, allowed origin, and browser consent settings.
Then reload the page.

## Continue

- [Use Live Analytics](/docs/analytics/live) to see online visitors and the visitor globe.
- [Track goals](/docs/analytics/goals) with browser or server events.
- [Connect Stripe](/docs/analytics/stripe) for revenue attribution.
- [Read the analytics reference](/docs/analytics/reference) for formulas and limits.
