# Report your site's events to help.ai

> Tell the AI agent what the visitor just did on your site, and count it, with track().

Your page knows things the chat doesn't: the plan the visitor is looking at, what's in their cart, the error they just saw. Tell help.ai with `track()`:

```js
const chat = await HelpAI.ready();
chat.track('plan_viewed', { plan: 'pro' });
chat.track('cart_updated', { items: 2, total: 48.5 });
```

## What each call does

- **The AI agent learns it.** The widget keeps your last 10 events and sends them, with how long ago each happened, along with the visitor's next message. The agent can say "I see you were looking at the Pro plan." It treats them as information from your site, never as instructions. They last for the page view.
- **It's counted.** Each call sends one usage event with its name and data, like the widget's own events. Nothing is sent when the widget's tracking is turned off (`tracking: { enabled: false }`) or the visitor's browser asks not to be tracked.

## What you can send

| | Rule |
| --- | --- |
| Name | 1 to 64 characters |
| Data | Optional. Flat: strings, numbers and true or false, with other values left out. Up to 256 characters as JSON; longer data isn't sent, but the name still is. |

Never put personal details in either: use ids and plan names, not emails or names.

## Other ways to call it

| How you installed | Call |
| --- | --- |
| **Quick install** script tag | `HelpAI('track', 'plan_viewed', { plan: 'pro' })`, which also works before the widget has loaded |
| `<web-ai-chat>` element | `element.track('plan_viewed', { plan: 'pro' })` |
| React kit | `useHelpAI().track('plan_viewed', { plan: 'pro' })` |

Each event also reaches your own listeners as `hostEvent`:

```js
chat.on('hostEvent', ({ name, data }) => console.log(name, data));
```

You need widget 1.11.0 or later.

<Tip>
To let the agent act on your page, not only know about it, use [page tools](https://docs.help.ai/page-tools/what-are-page-tools).
</Tip>
