Frameworks
Jekyll analytics with CrispStats
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.
Updated
Set up CrispStats on Jekyll
- 01
Step 1: Find the file that renders head
If your layouts live in your project, open the one that contains
<head>, often_layouts/default.htmlor_includes/head.html, and skip to the next step but one. - 02
Step 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
_includesor_layoutsfolder and Jekyll uses yours instead (see Jekyll’s theme docs). Copy the theme’shead.htmlfirst so you keep what it already does.# Where the gem-based theme keeps its files (Minima here)bundle info --path minima# Copy its head include into your site, then edit the copymkdir -p _includescp "$(bundle info --path minima)/_includes/ head. html" _includes/head.html - 03
Step 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
deferand do not addtype="module": the script reads its options from its own tag.Replace the highlighted values with your own.
_includes/head.html<scriptdeferdata-site="cs_pk_your_site_key"data-domains="example.com"src="https:/ / in. crispstats. com/ d. js"></script> - 04
Step 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 serveruns onlocalhost, which the script ignores on purpose. - 05
Step 5: Turn on more tracking (optional)
Add attributes to the same tag. In HTML a flag attribute is bare:
data-outboundcounts clicks to other sites anddata-downloadscounts file downloads.data-excludeleaves out paths you do not want tracked._includes/head.html<scriptdeferdata-site="cs_pk_your_site_key"data-domains="example.com"data-outbounddata-downloadssrc="https:/ / in. crispstats. com/ d. js"></script> - 06
Step 6: Count clicks from your templates (optional)
Add
data-cs-eventto an element, with properties fromdata-cs-prop-attributes. From your own JavaScript, callwindow.crispstats?.("newsletter signup").<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).
CrispStats on Jekyll
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, 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=newsletterstill 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 and limits
- GitHub Pages serves static files only, so it cannot run the forwarding rule 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, which do not run JavaScript; that needs edge code on your host.
- Keep your own visits out by setting
localStorage.crispstats_ignoreonce in your browser. See exclude traffic.
- GitHub Pages serves static files only, so it cannot run the forwarding rule that serves the script from your own domain. Load it from
The docs page covers the optional steps this guide leaves out.
Setup questions. Straight answers.
What people ask before they connect it.
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.
No. One script tag in your head include is the whole install, so it also works where GitHub Pages limits which plugins run.
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.
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.
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.
Not answered here? Write to hello@crispstats.com
Go further
Related
- Privacy-friendly analytics for bloggers
See which posts get read to the end, where readers come from, including AI assistants, and keep your site free of analytics cookies.
- Web analytics for developers
A small cookieless script with web vitals and error tracking, an npm SDK, a REST API and an MCP server, so your analytics fits the way you work.
- UTM builder
Build UTM-tagged links one at a time or in bulk from pasted rows, with presets, checks for capitals and spaces, CSV export and a channel preview.
- Do you need a cookie banner for analytics?
When analytics needs consent: what the device storage rule covers, where GDPR comes in, and a checklist.
- Hugo analytics
Add CrispStats to a Hugo site by pasting one script tag into the head partial every page uses, overriding the theme's copy.
- Ghost analytics
Add CrispStats to a Ghost publication: paste one script tag into Settings, Advanced, Code injection, Site header.
Other integrations
Frameworks
Site builders
Ecommerce platforms
Tag managers
Your traffic, crisp and clear
One script, no cookies, and every feature from the first day. Set up takes about as long as pasting a snippet.