# Tracker functions (https://talivia.com/docs/tracker-functions)



The tracker exposes a small browser API after the script loads.

## Track a page view [#track-a-page-view]

```js
window.talivia.track();
```

Use this when automatic tracking is disabled or when you need to manually send a page view after a route transition.

## Track a custom event [#track-a-custom-event]

```js
window.talivia.track('signup-button');
```

Event names are limited to 50 characters.

## Track an event with data [#track-an-event-with-data]

```js
window.talivia.track('signup-button', {
  plan: 'pro',
  location: 'pricing',
});
```

Event data can include strings, numbers, arrays, and nested objects. Keep payloads small: Talivia truncates long strings and limits object shape so reports stay fast.

## Override page properties [#override-page-properties]

```js
window.talivia.track({
  website: 'YOUR_WEBSITE_ID',
  url: '/pricing',
  title: 'Pricing',
});
```

## Use a function [#use-a-function]

```js
window.talivia.track(props => ({
  ...props,
  url: '/checkout',
  title: 'Checkout',
}));
```

The function receives the current tracker payload and returns the payload to send.

## Identify a visitor [#identify-a-visitor]

```js
window.talivia.identify('user_123', {
  email: 'founder@example.com',
  stripeCustomerId: 'cus_123',
});
```

Use identify after login or signup. Talivia stores session data and can connect a payment provider customer to the visitor.

## Read checkout context [#read-checkout-context]

```js
const sessionId = window.talivia.getSessionId();

await fetch('/api/create-checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ sessionId }),
});
```

`getSessionId()` returns the opaque value stored in the `talivia_session_id` first-party cookie. Send only this value to your backend and attach it as `talivia_session_id` provider metadata. It is an attribution identifier, not an authentication credential.
