# Event tracking

Page views tell you what people read. Events tell you what they did. A subscribe button pressed, a PDF downloaded, a form submitted: you name the action in your HTML and Tinylytics counts it. Events appear on the **Events** tab and are kept out of your page-view numbers, so measuring a click never inflates your traffic.

Event tracking is in beta. It works, and it may still gain a rough edge or two.

![Events tab](docs/events.png)

Add `?events` to your embed URL. Keep `defer` on the tag as usual.

```html
<script defer src="https://tinylytics.app/embed/YOUR_EMBED_CODE.js?events"></script>
```

You can combine it with the widget parameters, as in `?events&kudos&hits`. If hit collection is switched off for the site, or the script is loaded with `?ignore`, events do not fire either — the two travel together.

## Naming events

An event name is a category and an action joined by a dot: `button.click`, `file.download`, `form.submit`. The category is the part that pays off later, when the Events tab groups everything sensibly instead of handing you fifty unrelated words. A bare `click` is rejected for that reason. If arrows are easier to type, `button->click` is stored as `button.click`.

```html
<button data-tinylytics-event="button.subscribe">Subscribe</button>
```

You can attach a value when the action has an obvious detail worth keeping, such as which file was downloaded:

```html
<a href="/guides/guide.pdf"
   data-tinylytics-event="file.download"
   data-tinylytics-event-value="guide.pdf">
  Download the guide
</a>
```

Put the attribute on the element that actually gets clicked. For a form, that means the submit button.

## Clicks that leave the page

By default events are sent with `fetch`, which the browser is entitled to cancel if the click navigates away — exactly the situation for a download or an outbound link. Adding `?beacon` switches to `navigator.sendBeacon`, which is designed to survive the page unloading.

```html
<script defer src="https://tinylytics.app/embed/YOUR_EMBED_CODE.js?events&beacon"></script>
```

The trade is that some privacy-focused browsers block beacons outright, so neither method is complete on its own. If these events matter to you, try both on your own audience and keep whichever loses less.

One more detail worth knowing: the script debounces each element to one event every 500ms, so an impatient double-click counts once.

Once you have an event you care about, you can promote it to a [goal](/docs/analytics/goals) and get a conversion rate alongside it.