# Tracking overview (https://talivia.com/docs/tracking)



Talivia's browser tracker records page views automatically and exposes a small JavaScript API for custom events, identity, and checkout attribution.

## Script [#script]

```html
<script
  defer
  src="https://talivia.com/script.js"
  data-website-id="YOUR_WEBSITE_ID"
  data-domain="example.com"
></script>
```

The script reads browser context, watches client-side route changes, and sends page views. By default, Talivia keeps an anonymous visitor cookie for one year and a rolling 30-minute session cookie.

A single hostname works without `data-domain`. Talivia Cloud includes it in the generated snippet so `example.com`, `app.example.com`, and other subdomains can share the same visitor and session when needed. Keep the complete snippet from **Settings -> Tracking** instead of rebuilding it from this example.

Use [Tracker configuration](https://talivia.com/docs/tracker-configuration) for optional script settings and [Subdomain tracking](https://talivia.com/docs/subdomain-tracking) for a complete shared-cookie setup.

## Runtime API [#runtime-api]

When the script loads, it creates `window.talivia`:

```js
window.talivia.track();
window.talivia.track('signup-click');
window.talivia.identify('user_123', { email: 'founder@example.com' });
window.talivia.getSessionId();
```

## Collection endpoint [#collection-endpoint]

The tracker sends data to Talivia's collection endpoint and receives signed cache and cross-domain tokens. Tokens are short-lived and contain anonymous tracking keys, not account or payment credentials.

## Revenue context [#revenue-context]

For checkout flows, follow the connected provider's revenue guide. Stripe and Yolfi use a unique
Checkout Session ID on the browser return. Providers without that return signal can use
`window.talivia.getSessionId()` in their supported checkout metadata.
