# Add CrispStats to a plain HTML site

Updated 2026-11-23

To add analytics to a plain HTML site, paste one script tag inside the head of every page and publish. CrispStats then counts pageviews, sources and time on page with no build step, no cookies and nothing stored on the visitor's device.

## Steps

### 1. Copy the snippet with your key

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

```html
<script
  defer
  data-site="cs_pk_your_site_key"
  data-domains="example.com"
  src="https://in.crispstats.com/d.js"
></script>
```

### 2. Paste it inside the head on every page

Put the tag inside `<head>`. If your pages share a header include or a template in your static site generator, add it there once; if every page is its own file, add it to each one. 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.

`index.html`

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example</title>
    <script
      defer
      data-site="cs_pk_your_site_key"
      data-domains="example.com"
      src="https://in.crispstats.com/d.js"
    ></script>
  </head>
  <body>
    <h1>Hello</h1>
  </body>
</html>
```

### 3. Publish and open the live site

Upload the files or push to your host, then open the live site in a normal browser window. Pages on `localhost`, `127.0.0.1`, `[::1]` and `file://` are ignored, so opening the file from your disk or a local preview does not count, and neither do automated browsers ([localhost and testing](/docs/tracking/localhost-and-testing)).

### 4. Turn on optional modules

Each module starts working when its attribute is on the tag: `data-outbound` for clicks on links to other sites, `data-downloads` for file downloads, `data-vitals` for LCP, INP, CLS, FCP and TTFB, `data-errors` for uncaught JavaScript errors, and `data-404` for pages that contain `<meta name="crispstats:404">`. The switches under **Extra events** on the **Tracking code** tab add them for you.

```html
<script
  defer
  data-site="cs_pk_your_site_key"
  data-domains="example.com"
  data-outbound
  data-downloads
  data-vitals
  data-errors
  data-404
  src="https://in.crispstats.com/d.js"
></script>
```

### 5. Count a button with no JavaScript (optional)

Add `data-cs-event` to any element to count clicks on it as a [custom event](/glossary/custom-event). Properties come from `data-cs-prop-` attributes.

```html
<button data-cs-event="newsletter signup" data-cs-prop-place="footer">
  Subscribe
</button>
```

## Check that it works

The status row at the top of **Settings**, **Tracking code** checks the install every five seconds while the tab is open. It moves from **Waiting for the first event…** to **Receiving events.** once the first event is stored, and the visit appears on **Realtime**. If it stays waiting, check for an ad blocker in your own browser, a cached copy of the page without the tag, a Content Security Policy that does not allow `in.crispstats.com`, or `localStorage.crispstats_ignore` set in your browser.

## What you get

- Pageviews, [unique visitors](/glossary/unique-visitor), sessions and time on page for every page that carries the tag.
- Where visitors come from: search, social, referrers, UTM campaigns and AI assistants such as ChatGPT and Perplexity.
- Countries, devices and browsers, from a visitor id that is a daily rotating hash, never a cookie.
- Outbound clicks, downloads, 404s, web vitals and JavaScript errors, each from one attribute.
- A core script of about 2.2 KB gzipped, about 3.8 KB with every module on, loaded with defer so it never blocks rendering.

## Notes for HTML

- A static site with many hand-written files needs the tag in every file. A page without it is simply not counted, with no error anywhere.
- `data-domains` limits counting to the hostnames you list. A copy of the site on a staging host or a preview URL sends nothing until you add that hostname.
- If the site's URLs look like `/#/pricing`, add `data-hash` so each hash route counts as a page. Ordinary anchors such as `#faq` are not pages.
- A purely static host runs no code of yours, so the forwarding proxy for ad-blocked visitors needs a host or CDN that can forward a path, such as [Cloudflare](/integrations/cloudflare), [Netlify](/integrations/netlify), [Vercel](/integrations/vercel) or nginx: see [the proxy guide](/docs/tracking/proxy).
- Only a Plausible export can be imported. Otherwise history in CrispStats starts the day the tag goes live.

Full reference: [HTML in the docs](https://docs.crispstats.com/install/html)

## Frequently asked questions

### Where do I put the analytics script in HTML?

Inside the head element, on every page you want counted. With defer it loads after the page has been parsed, so the position inside the head does not delay rendering.

### Does it work without a build step or npm?

Yes. The script is one tag that loads from the collector host, so a site of plain files with no package manager, bundler or framework is fully supported.

### Can I test it on my computer before I publish?

Local pages are ignored by default. Add data-debug and add localhost to data-domains while you test: each event is logged in the browser console and nothing is sent.

### How much does analytics for a small HTML site cost?

Nothing for the first 14 days: every account starts with a 14-day free trial with every feature and no card. After that Starter is $5 a month for 250,000 events, which covers most small sites. There is no free plan.

## Related

- [Cookieless analytics explained](/blog/cookieless-analytics-explained)
- [Privacy-friendly analytics for bloggers](/for/bloggers)
- [Web vitals from real visits](/features/web-vitals)
- [UTM builder](/tools/utm-builder)
- [Install through Google Tag Manager](/integrations/google-tag-manager)
