> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Track outbound links and file downloads

> Turn on data-outbound and data-downloads to record clicks on external links and file links as Outbound link and File download events, and see what their url prop contains.

CrispStats can record clicks on links to other sites and on links to files, with one attribute each on the script tag. `data-outbound` sends an `Outbound link` event and `data-downloads` sends a `File download` event, both with the link's address in the `url` property. Both are off until you add the attribute, and neither needs any change to your links.

```html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script defer data-site="cs_pk_xxxxxxxx" data-outbound data-downloads src="https://in.crispstats.com/d.js"></script>
```

## Turn the modules on

**1. Add the attributes to the script tag**

Add `data-outbound`, `data-downloads` or both to your existing tag, as above. They are flags: the attribute's presence turns the module on. Use `d.js`, the default script: the smaller `d.core.js` build leaves these modules out and ignores the attributes.

**2. Click a link on your live site**

Click a link to another website, or a link to a PDF.

**3. Find the events in the dashboard**

Open **Events**. `Outbound link` and `File download` appear next to your own custom events. Select one, then select the `url` property to see which links were clicked.

## Outbound links

With `data-outbound`, a click on a link sends:

| Field | Value |
| - | - |
| Event name | `Outbound link` |
| Property `url` | The link's full `href`, cut to 500 characters. |

A click counts when the link uses `http:` or `https:` and points to a different host than the current page. The host includes the port and the subdomain, so a link from `www.example.com` to `docs.example.com` is outbound. Links to `mailto:`, `tel:` and other schemes are not tracked.

Clicks anywhere inside the `<a>` element count, and so do middle clicks, which open the link in a new tab. Opening a link from the right-click menu is not a click and is not counted.

## File downloads

With `data-downloads`, a click on a link sends:

| Field | Value |
| - | - |
| Event name | `File download` |
| Property `url` | The link's full `href`, cut to 500 characters. |

A click counts when the link has a `download` attribute, or when its path ends in a known extension. The query string is ignored, and the match does not depend on case. Middle clicks count too. Links to files on other hosts count as well, so a click on an external PDF sends both `Outbound link` and `File download` when both modules are on.

The default extensions are:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
pdf, xlsx, docx, txt, rtf, csv, exe, key, pps, ppt, pptx, 7z, pkg, rar, gz, zip, avi, mov, mp4, mpeg, wmv, midi, mp3, wav, wma, dmg
```

To track other file types, give the attribute a list of extensions in lowercase, separated by commas or spaces. Your list replaces the default one, so include every extension you want:

```html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script defer data-site="cs_pk_xxxxxxxx" data-downloads="pdf, epub, zip" src="https://in.crispstats.com/d.js"></script>
```

To track one link whatever its extension, add the `download` attribute to it:

```html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<a href="/reports/2026-annual" download>Download the annual report</a>
```

## What the url contains

The `url` prop is the link's address, up to 500 characters, without its fragment. Its query string is cut in the browser the same way as the page URL: only the [kept parameters](https://docs.crispstats.com/tracking/script-attributes.md#what-the-script-sends) stay, so signed or private query strings, such as presigned storage URLs, are not sent.

## Next steps

> [card] [Script attributes](https://docs.crispstats.com/tracking/script-attributes.md)
>
> Every attribute the script tag accepts, including the other optional modules.

> [card] [Track 404 pages](https://docs.crispstats.com/track/404-pages.md)
>
> Find broken links by recording visits to not-found pages.

> [card] [Set up goals](https://docs.crispstats.com/dashboard/goals.md)
>
> Count a download or an outbound click as a conversion.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.