# Track events (https://talivia.com/docs/track-events)



Use custom events for actions that matter more than a page view: signups, checkout clicks, demo requests, external links, and activation steps.

## HTML attributes [#html-attributes]

Add `data-talivia-event` to an element:

```html
<button data-talivia-event="signup-click">Start free trial</button>
```

Add event data with `data-talivia-event-*` attributes:

```html
<button
  data-talivia-event="checkout-click"
  data-talivia-event-plan="pro"
  data-talivia-event-location="pricing"
>
  Checkout
</button>
```

Talivia automatically reads these attributes on click.

## Track when an element becomes visible [#track-when-an-element-becomes-visible]

Add `data-talivia-visible` to any element that matters: a pricing section, CTA, banner, alert, or modal.

```html
<section data-talivia-visible="pricing-seen">
  <h2>Simple pricing</h2>
</section>
```

Talivia sends the `pricing-seen` event once per page view when 50% of the element is visible.

Use optional attributes when the default is not right for an element:

```html
<button
  data-talivia-visible="signup-cta-seen"
  data-talivia-visible-threshold="0.7"
  data-talivia-visible-delay="700"
>
  Start free trial
</button>
```

* `data-talivia-visible-threshold` accepts `0.1` through `1`. The default is `0.5`.
* `data-talivia-visible-delay` waits for the element to remain visible before sending the event. The default is `0` milliseconds.

Visibility events include `visibility_percentage`, `threshold`, and `delay` in their event data. They work like any other Talivia event in Sessions, Goals, and Funnels.

## Links [#links]

For normal links, Talivia waits for the event request before navigating when possible.

```html
<a href="/pricing" data-talivia-event="pricing-link">Pricing</a>
```

External links, modifier-key clicks, and `_blank` links are not blocked.

## JavaScript [#javascript]

```js
window.talivia.track('invite-sent', {
  role: 'viewer',
});
```

Use JavaScript when the event depends on application state, form results, or a server response.

## Event data tips [#event-data-tips]

* Use stable names like `signup-click`, not user-facing button text.
* Keep numeric values as numbers when you want to compare them later.
* Avoid sending personal information unless it is needed for payment attribution and allowed by your privacy policy.
