> ## 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.

# Install CrispStats on a plain HTML site

> Add the CrispStats script tag to the head of every page of a static or server-rendered HTML site, turn on optional modules and confirm the install.

To install CrispStats on a plain HTML site, paste one `<script>` tag inside `<head>` on every page and deploy. The script then tracks pageviews, single-page navigation and time on page. By default it sets no cookie and stores nothing on the visitor's device. This guide also covers the optional modules and how to confirm that events arrive.

## Add the script

**1. Copy the snippet**

In the dashboard, open your site's **Settings** and select **Tracking code**. The **HTML** tab shows the tag with your public key filled in. You can also copy it from the command menu with **Copy tracking snippet**.

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

**2. Paste it inside head on every page**

Put the tag inside `<head>`. If your pages share a header include or template, add it there once.

```html index.html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example</title>
    <script
      defer
      data-site="cs_pk_xxxxxxxx"
      data-domains="example.com"
      src="https://in.crispstats.com/d.js"
    ></script>
  </head>
  <body>
    <h1>Hello</h1>
  </body>
</html>
```

Keep `defer` (or use `async`) and do not add `type="module"`: the script reads its options from its own tag, which a module script cannot do.

**3. Deploy and open your site**

Publish the change, then open your live site in a normal browser window. Pages on `localhost`, `*.localhost`, `127.x.x.x`, `[::1]` and `file://` are ignored, so a local preview does not count, and neither do automated browsers. See [localhost and testing](https://docs.crispstats.com/tracking/localhost-and-testing.md) to test before you ship.

## Turn on optional modules

The base script tracks pageviews and engagement. Each optional module starts working when its attribute is on the tag. On the **Tracking code** tab, the switches under **Extra events** and **How pages are counted** add these attributes to the snippet for you.

| Attribute | What it sends |
| - | - |
| `data-outbound` | An `Outbound link` event with the `url`, for clicks and middle clicks on `http` and `https` links to another host. |
| `data-downloads` | A `File download` event with the `url`, for links with a `download` attribute or a file extension such as pdf, zip, csv or dmg. Give a list to replace the defaults: `data-downloads="pdf, epub"`. |
| `data-vitals` | LCP, INP, CLS, FCP and TTFB from real visits, for the Performance page. |
| `data-errors` | Uncaught errors and unhandled promise rejections, for the Errors page. Each distinct error is sent once, ten per page load at most. |
| `data-404` | A `404` event with the `path` on pages that contain `<meta name="crispstats:404">`. Give a CSS selector to also match pages that contain such an element: `data-404=".not-found"`. |

Two more switches change how pages are counted: **Hash routing** (`data-hash`, only for sites whose URLs look like `/#/pricing`) and **Manual pageviews** (`data-manual`). See [single-page apps](https://docs.crispstats.com/tracking/single-page-apps.md).

With every module on, the tag looks like this:

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

The switches only change the snippet shown in the dashboard. A module starts working once the updated tag is on your site. Other attributes, such as `data-exclude`, `data-keep-params` and `data-debug`, are described in [script attributes](https://docs.crispstats.com/tracking/script-attributes.md).

## Confirm the install

The status row at the top of the **Tracking code** tab checks the install every five seconds while the tab is open, and you can select **Check again** to ask at once. It shows one of these states:

| Status | Meaning |
| - | - |
| **Checking the install…** | The first answer has not arrived yet. |
| **Waiting for the first event…** | No event from this site has been stored yet. Add the script, then open your site in a browser. |
| **Receiving events.** | The collector has stored at least one event for the site. The row also shows when the last event arrived, for example "Last event 12 seconds ago.", or "No visitors in the last few minutes." |
| **The check is not answering.** | The dashboard could not reach the check. It keeps trying, and your tracking is not affected. |

Once the status reads **Receiving events.**, open **Realtime** or the overview to see the visit.

If the status stays on **Waiting for the first event…** after you have opened your live site, check for:

* An ad blocker or privacy extension in your browser that blocks `in.crispstats.com`. See [ad blockers](https://docs.crispstats.com/help/ad-blockers.md).
* A Content Security Policy that does not allow `in.crispstats.com` for scripts and connections. See [Content Security Policy](https://docs.crispstats.com/help/content-security-policy.md).
* A cached copy of the page without the tag.
* `localStorage.crispstats_ignore` set to `"1"` in your browser, which turns tracking off for that browser. See [exclude traffic](https://docs.crispstats.com/tracking/exclude-traffic.md).

[Troubleshooting](https://docs.crispstats.com/help/troubleshooting.md) walks through each cause.

## Next steps

> [card] [Track custom events](https://docs.crispstats.com/track/custom-events.md)
>
> Send signups, purchases and other actions with `crispstats()`.

> [card] [Exclude your own visits](https://docs.crispstats.com/tracking/exclude-traffic.md)
>
> Keep your browser and private paths out of the numbers.

> [card] [Script attributes](https://docs.crispstats.com/tracking/script-attributes.md)
>
> Every option the script tag accepts.


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