Static site generators · 3 min setup
How to add analytics to a Jekyll site
_includes/custom-head.html on themes that provide it, or a copy of the theme's _includes/head.html — inside {% if jekyll.environment == "production" %}. GitHub Pages builds in production, so the tag goes live on your next push.Updated
Gem-based themes keep their files inside the gem, so you override them by creating a file with the same path in your site. Minima 2.5 — the version GitHub Pages uses by default — has no custom-head.html hook, so you copy its head.html; Minima 3 and many other themes provide a hook file meant exactly for this.
Jekyll at a glance
- Where the tag goes
_includes/custom-head.htmlor an overridden_includes/head.html- Production only
jekyll.environment == "production"- GitHub Pages
- Builds with
JEKYLL_ENV=production— tag included - Config
visitrack_site_idin_config.yml- Link goals
- kramdown attribute lists on links
How to install VisitTrack on Jekyll
Step 1: Add your site id to _config.yml
Copy the id from VisitTrack's install step.
_config.ymlvisitrack_site_id: SITE_IDStep 2: Find the head include
If your theme has
_includes/custom-head.html(Minima 3 and others), create that file in your site. Otherwise copy the theme's_includes/head.htmlinto your site's_includes/folder —bundle info --path minima(or your theme's name) prints where the gem lives.Step 3: Add the tag, production only
jekyll serveruns in the development environment by default, so local previews never load it._includes/custom-head.html (or head.html, before </head>){% if jekyll.environment == "production" and site.visitrack_site_id %} <script defer data-site="{{ site.visitrack_site_id }}" src="https://visitrack.app/tracker.js"></script> {% endif %}Step 4: Build and push
Commit and push. GitHub Pages and most CI builds set
JEKYLL_ENV=production; for a manual build, runJEKYLL_ENV=production bundle exec jekyll build.
How to check VisitTrack is working on Jekyll
- Search
_site/index.htmlafter a production build fortracker.js. - Open the published site and read two posts; the VisitTrack live view shows you within seconds.
- If nothing shows on GitHub Pages, check the Actions/Pages build log — a theme override in the wrong folder is the usual cause.
Does VisitTrack track Jekyll page navigation?
Jekyll generates static HTML, so each page is a full page load and one pageview. With permalink: pretty, posts appear as /2026/09/30/my-post/; paginated index pages (/page2/) are separate paths.
GitHub Pages serves your custom domain and username.github.io — if both are reachable, save the custom domain under Settings → General → Allowed hostnames.
How to track custom events and goals in Jekyll
Jekyll's default Markdown engine, kramdown, lets you attach attributes to a link with an inline attribute list — so goals work straight from your posts:
[Start your free trial](https://app.example.com/signup){: data-vt-goal="blog_trial_click"}
<!-- in _layouts/post.html, near the end -->
<div data-vt-scroll="post_finished"></div>Outbound links, mailto: clicks and file downloads (PDFs, zips) are tracked automatically. Make the events goals in Settings → Goals.
Script options you might need on Jekyll
All optional — add them to the same tag. Full reference: script configuration.
| Attribute | What it does |
|---|---|
data-cookieless | Store nothing in the browser; the server derives a daily-rotating id. See cookieless mode. |
data-exclude="/app/*" | Never track these paths (comma-separated, * wildcard). Checked on every navigation. |
data-allow-local | Track on localhost and *.local — for testing an install only. |
data-debug | Log every event the script sends, and why it skipped one, to the console. |
data-auto="false" | Turn off automatic events (downloads, contact clicks, form submits, rage clicks, JS errors, 404s). |
Jekyll troubleshooting
The override has no effect
It must be at _includes/head.html (same name as the theme's) in your site root, not in a subfolder. For custom-head.html, your theme version must actually include it — Minima 2.5 doesn't.
The tag appears locally but not on GitHub Pages
A remote theme or a different Minima version is in use on Pages. Check remote_theme / theme in _config.yml and which head file that version includes.
Nothing in the built HTML
The build wasn't in production. Set JEKYLL_ENV=production for manual or CI builds.
The kramdown attribute shows up as text
The {: … } list must follow the link with no space, and the site must use kramdown (Jekyll's default).
Jekyll analytics FAQ
How do I add analytics to GitHub Pages?
With Jekyll, add the script tag to your theme's head include (custom-head.html or an overridden head.html) and push. GitHub Pages builds in production mode, so the tag is included on the live site.
Where is head.html in the Minima theme?
Inside the theme gem. Run bundle info --path minima to find it, then copy _includes/head.html into your site's _includes folder and edit the copy.
Will jekyll serve send data to VisitTrack?
No. With the jekyll.environment check, the tag isn't rendered in development, and the script ignores localhost anyway.
Can I track link clicks in Jekyll posts?
Yes. Outbound links are tracked automatically; for a named goal, add {: data-vt-goal="name"} after the Markdown link.
Does VisitTrack work with Jekyll themes other than Minima?
Yes. Any theme renders a <head>; find the include that renders it (often head.html or a custom-head hook) and add the tag there.
Keep going
- Hugo analyticsAdd VisitTrack to a Hugo site through your theme's head partial, loaded only in production with hugo.IsProduction, plus a shortcode for goals.
- Ghost analyticsAdd VisitTrack to Ghost in Settings → Code injection → Site header (every Ghost(Pro) plan and self-hosted) and count confirmed member signups.
- Docusaurus analyticsAdd VisitTrack to Docusaurus with the scripts array in docusaurus.config — data attributes supported, client-side navigation tracked automatically.
- Netlify analyticsAdd VisitTrack on Netlify with Snippet injection (no code) or in your framework, keep deploy previews out, and set CSP in _headers.
- Install the tracking scriptThe reference tag, CSP notes and how to check it's working.
- Custom events and signupsvisitrack(), data-vt-goal, scroll events and server-side signups.
- Use casesHow SaaS teams, indie hackers, stores and agencies use VisitTrack.
- VisitTrack vs Google AnalyticsCookie-free analytics with revenue attribution, compared honestly.
Add VisitTrack to your Jekyll site
Cookie-free analytics with revenue attribution, live visitors, funnels and session replays. One script tag, every feature on every plan. 14 days free, no card required.
Not on Jekyll? See all 29 integration guides.