<head> in the include or layout every page uses, usually _includes/head.html or _layouts/default.html. Rebuild and deploy, and every page is tracked. Jekyll pages are plain HTML files, so each page load is one pageview.
You need your site’s public key, which starts with cs_pk_. Find it in your site’s settings under Tracking code, on the HTML tab. The key is safe to publish.
Add the script
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.If they come from a gem-based theme such as Minima, the files are inside the gem. To change one, create a file with the same name in your site’s own _includes or _layouts folder: Jekyll uses your file instead of the theme’s. Copy the theme’s head.html into _includes/head.html first so you keep what it already does. bundle info --path minima prints where the gem’s files are.2
Paste the tag inside head
_includes/head.html
defer and do not add type="module": the script reads its options from its own tag.3
Build and deploy
Run
bundle exec jekyll build, or push to the branch your host builds from. jekyll serve runs on localhost, which the script ignores, so a local preview does not count. Open your live site in a normal browser window.Turn on more tracking (optional)
Add attributes to the same tag. In HTML, a flag attribute is bare:_includes/head.html
data-exclude for paths you do not want tracked.
Check that it works
- In your browser’s developer tools, the Network tab shows
d.jsloading fromin.crispstats.comand aPOSTtohttps://in.crispstats.com/ethat gets202. - In CrispStats, Settings, Tracking code shows Receiving events., and the visit appears in Realtime within seconds.
- Search a built page in
_site/forin.crispstats.com/d.js. If it is missing, Jekyll is still using the theme’s file: check that your copy has exactly the same name and folder.
jekyll serve, add data-debug and localhost in data-domains while you develop. See localhost and testing.
How page changes are counted
Each Jekyll page is a full page load, so the script counts one pageview per page. Anchor links within a page are not new pages. Query strings are cut before sending, except UTM parameters and a few other campaign parameters, so?utm_source=newsletter still sets the source. See script attributes.
Send custom events
For clicks, adddata-cs-event to the element in your template:
window.crispstats?.("newsletter signup"). See custom events.
FAQ
Does it work on GitHub Pages?
Does it work on GitHub Pages?
Yes. The tag is part of the HTML Jekyll builds, so it works on any static host. A forwarding proxy needs a host that can run a server rule. On a host that only serves static files, load the script from
in.crispstats.com as shown here.Do I need a Jekyll plugin?
Do I need a Jekyll plugin?
No. One tag in your head include is the whole install.
Will a theme update remove the tag?
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.Next steps
Declarative events
Track clicks with attributes in your templates.
Exclude traffic
Keep your own visits out of the numbers.
Ad blockers
What blockers hide and how a proxy helps.
Jekyll details (overriding a theme file with a file of the same name in your site’s
_includes or _layouts folder) checked against https://jekyllrb.com/docs/themes/ on 2026-11-23.