# Jekyll analytics with CrispStats

Updated 2026-11-23

On a Jekyll site, CrispStats is one script tag inside the head of the include or layout every page uses, usually _includes/head.html or _layouts/default.html. Rebuild and deploy, and every page is tracked; it works on GitHub Pages and any other static host, with no plugin.

## Steps

### 1. Find the file that renders head

If your layouts live in your project, open the one that contains `<head>`, often `_layouts/default.html` or `_includes/head.html`, and skip to the next step but one.

### 2. Override a gem-based theme's file

With a gem-based theme such as Minima, the files are inside the gem. Create a file with the same name in your site's own `_includes` or `_layouts` folder and Jekyll uses yours instead (see [Jekyll's theme docs](https://jekyllrb.com/docs/themes/)). Copy the theme's `head.html` first so you keep what it already does.

```bash
# Where the gem-based theme keeps its files (Minima here)
bundle info --path minima

# Copy its head include into your site, then edit the copy
mkdir -p _includes
cp "$(bundle info --path minima)/_includes/head.html" _includes/head.html
```

### 3. Paste the tag inside head

Copy the tag from **Settings**, **Tracking code**, **HTML** in the CrispStats dashboard, with your public key and domain filled in. Keep `defer` and do not add `type="module"`: the script reads its options from its own tag.

`_includes/head.html`

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

### 4. Build and deploy

Run `bundle exec jekyll build`, or push to the branch GitHub Pages or your host builds from. Then open the live site in a normal browser window. `jekyll serve` runs on `localhost`, which the script ignores on purpose.

### 5. Turn on more tracking (optional)

Add attributes to the same tag. In HTML a flag attribute is bare: `data-outbound` counts clicks to other sites and `data-downloads` counts file downloads. `data-exclude` leaves out paths you do not want tracked.

`_includes/head.html`

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

### 6. Count clicks from your templates (optional)

Add `data-cs-event` to an element, with properties from `data-cs-prop-` attributes. From your own JavaScript, call `window.crispstats?.("newsletter signup")`.

```html
<a href="/download/guide.pdf" data-cs-event="guide download" data-cs-prop-format="pdf">Get the guide</a>
```

## Check that it works

On your live site, the developer tools' **Network** tab shows `d.js` loading from `in.crispstats.com` and a `POST` to `/e` that gets `202`. In CrispStats, **Settings**, **Tracking code** shows **Receiving events.** and the visit appears on the **Realtime** screen within seconds. If nothing arrives, search a built page in `_site/` for `in.crispstats.com/d.js`: if it is missing, Jekyll is still using the theme's file, so check that your copy has exactly the same name and folder. To watch events on `jekyll serve`, add `data-debug` and `localhost` in `data-domains` while you develop ([localhost and testing](/docs/tracking/localhost-and-testing)).

## What you get

- Pageviews, unique visitors and sessions for every post and page Jekyll builds, with entry and exit pages.
- Sources and channels: search, social, newsletters tagged with [UTM parameters](/glossary/utm-parameters), and visits from AI assistants such as ChatGPT and Perplexity.
- Campaigns kept intact: query strings are cut before sending, except UTM parameters and a few other campaign parameters, so `?utm_source=newsletter` still sets the source.
- A core script of about 2.2 KB gzipped, loaded with `defer`, so the page renders before it runs.
- Downloads of the PDFs and files you link to, and outbound clicks, once the two flags are on.

## Notes for Jekyll

- GitHub Pages serves static files only, so it cannot run the [forwarding rule](/docs/tracking/proxy) that serves the script from your own domain. Load it from `in.crispstats.com`; visitors whose ad blocker stops that host are not counted. If your custom domain runs through Cloudflare, a Worker route on it can do the forwarding.
- On a host that can run a forwarding rule (Netlify, Vercel, Cloudflare, nginx), the proxy is available and lets more visits through ad blockers.
- Each Jekyll page is a full page load, so one pageview per page. Anchor links within a page are not new pages.
- A static Jekyll site cannot report AI crawlers such as [GPTBot](/bots/gptbot), which do not run JavaScript; that needs edge code on your host.
- Keep your own visits out by setting `localStorage.crispstats_ignore` once in your browser. See [exclude traffic](/docs/tracking/exclude-traffic).

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

## Frequently asked questions

### Does it work on GitHub Pages?

Yes. The tag is part of the HTML Jekyll builds, so it works on GitHub Pages and any other static host. Only the optional forwarding proxy needs a host that can run a server rule.

### Do I need a Jekyll plugin for analytics?

No. One script tag in your head include is the whole install, so it also works where GitHub Pages limits which plugins run.

### Will a theme update remove the tag?

Not when the tag is in your own _includes or _layouts copy. Your file overrides the theme's file of the same name, and a gem update does not touch it.

### How do I keep my own visits out?

jekyll serve runs on localhost, which the script ignores. For the live site, set localStorage.crispstats_ignore to 1 once in your browser's console, and that browser is left out from then on.

### What does it cost for a Jekyll blog?

For a blog on GitHub Pages, events are your pageviews plus any data-cs-event clicks. Every account starts with a 14-day free trial with every feature and no card; then Starter is $5 a month for 250,000 events.

## Related

- [Privacy-friendly analytics for bloggers](/for/bloggers)
- [Web analytics for developers](/for/developers)
- [UTM builder](/tools/utm-builder)
- [Do you need a cookie banner for analytics?](/blog/do-you-need-a-cookie-banner-for-analytics)
- [Hugo analytics](/integrations/hugo)
- [Ghost analytics](/integrations/ghost)
