# Links and downloads

Count clicks on links to other sites and on files people download, with one attribute on the snippet.

The script can record two kinds of clicks with no code on your side: links that leave your site, and files people download. Both arrive as [custom events](/docs/tracking/custom-events), so the Events page, goals and funnels handle them like any event you send yourself. Both are off until you turn them on.

## Turn them on

Add `data-outbound`, `data-downloads` or both to the snippet.

```html
<script defer src="https://cdn.ultanimus.com/s.js" data-site="YOUR_SITE_ID" data-outbound data-downloads></script>
```

With the [Next.js](/docs/install/nextjs) or [React](/docs/install/react) package, pass the same two props.

```tsx
<Analytics site="YOUR_SITE_ID" outbound downloads />
```

Turning either on loads a second file of under 1 KB gzipped.

## What counts

| Event | Sent when someone clicks | Its `url` |
|---|---|---|
| `outbound_link` | A link to another hostname | `github.com/acme/app` |
| `file_download` | A link to a file, or any link with the `download` attribute | `acme.com/files/guide.pdf` |

- One click sends one event. A file on another site counts as a download when `data-downloads` is on, and as an outbound link when only `data-outbound` is.
- `www.acme.com` and `acme.com` are the same host. Other subdomains are not, so a link from `acme.com` to `app.acme.com` is an outbound link.
- A click, a middle click and Enter on a focused link all count. Opening a link from the right-click menu does not.
- `mailto:` and `tel:` links send nothing.

A file is a link whose path ends in one of these extensions, in any case:

- Documents: `pdf doc docx xls xlsx ppt pptx key csv txt rtf epub`
- Archives and disk images: `zip gz tgz rar 7z iso dmg`
- Installers: `exe msi pkg deb rpm apk`
- Audio and video: `mp3 wav mp4 mov avi mkv`

## What the url keeps

`url` is the link's host and path. The script drops the query string and the fragment, where tokens and email addresses often sit, and a trailing slash. A click on `https://github.com/acme/app/?ref=home` sends `github.com/acme/app`.

## See them in the dashboard

Open `outbound_link` or `file_download` on the [Events page](/docs/dashboard/events). Its `url` tab ranks the links or files by visitors, and a click on one filters by it. The Activity feed on the [Realtime](/docs/dashboard/realtime) page shows each click within a second, with the link the visitor followed and the page they clicked it on. Make either event a [goal](/docs/tracking/goals-and-funnels) to count every outbound click or every download as a conversion.

> **Tip:** Each click is one event, so it counts toward your plan's monthly events like any custom event.
