How to add analytics to HTML website

For a hand-written HTML site, paste one line into the <head> of each page. If your pages share a header include or template, add it once there.

No cookies, no banner ~3 KB script About 2 minutes

Before you start

Create a free Cool Analytics account and add your site. You'll get a site ID — replace YOUR_SITE_ID in the code below with it. The dashboard shows the snippet with your ID already filled in.

Install on HTML website

  1. 1Open each HTML page (or your shared header template).
  2. 2Paste the snippet just before the closing </head> tag.
  3. 3Upload the changed files to your host.
index.html
<script defer src="https://coolanalytics.dev/hb.js" data-site="YOUR_SITE_ID"></script>

Check that it works

Open your live site in a new tab, then open your Cool Analytics dashboard. Your visit appears on the live map within seconds — with the page you're on, where you came from and your browser.

Nothing showing up? Make sure you're looking at the published site (not a preview or editor), that an ad blocker isn't blocking the script, and that you're not testing on localhost.

Track signups, purchases and clicks

Pageviews, sources, countries and outbound link clicks are tracked automatically. For the moments that matter to you, send a custom event. Events named like a signup show up as signups, and events with an amount show up as revenue — on the live map and per traffic source.

custom events
// anywhere in your HTML website site's browser code
window.hb?.track("signup");

// with an amount, it shows up as revenue
window.hb?.track("purchase", { amount: 49 });

HTML website tips

  • Pages without the snippet won't be counted — search your project for </head> to make sure every page has it.
  • Works on any host: GitHub Pages, Netlify, Cloudflare Pages, shared hosting or your own server.
  • Visits from localhost are ignored so your own development doesn't count. To test locally, add data-dev="1" to the script tag for a moment — then remove it.

Want to keep your own visits out of the stats? Open your site once with #hb-ignore at the end of the URL. That browser is excluded until you visit with #hb-track.

HTML website analytics FAQ

Do I need a build step?+

No. It's a plain script tag that works on any static page.

Where exactly in the <head>?+

Anywhere inside <head>. Thanks to defer it never blocks the page from rendering.

Can I track a download link?+

Clicks on links to other domains are tracked automatically. For a file download on your own site, add onclick="hb.track('download')" to the link.

See who's on your HTML website site right now.

One line of code. No cookies. 7 days free.