Jekyll
Add Rybbit analytics to your Jekyll site
Jekyll renders every page through a layout, usually _layouts/default.html. Put the snippet in an include file that the layout pulls in, or paste it into the layout directly.
Get your tracking snippet
In your Rybbit dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:
<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>YOUR_SITE_ID is the numeric ID of your site. If you self-host Rybbit, app.rybbit.io is the domain of your own instance.
Add the snippet to Jekyll
-
Add your site ID to
_config.yml.rybbit_instance_urlis only needed if you self-host:_config.yml rybbit_site_id: "YOUR_SITE_ID" rybbit_instance_url: "https://app.rybbit.io" -
Create
_includes/rybbit-analytics.html(create the_includes/directory if it does not exist):_includes/rybbit-analytics.html {% if jekyll.environment == "production" and site.rybbit_site_id %} <script src="{{ site.rybbit_instance_url | default: 'https://app.rybbit.io' }}/api/script.js?siteId={{ site.rybbit_site_id }}" defer></script> {% endif %}The
jekyll.environmentcheck keeps the script out of localjekyll servebuilds; thesite.rybbit_site_idcheck keeps it out of builds with no ID configured. -
Include it from your layout's
<head>:_layouts/default.html <head> ... {% include rybbit-analytics.html %} </head>
Open _layouts/default.html and paste the snippet inside <head>, wrapped in a production check so local jekyll serve builds are not tracked:
<head>
...
{% if jekyll.environment == "production" %}
<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>
{% endif %}
</head>Build for production and deploy the generated _site/ directory:
JEKYLL_ENV=production jekyll buildGitHub Pages sets jekyll.environment to production during its own build, so no extra configuration is needed there.
Verify installation
Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Rybbit dashboard.
If nothing shows up:
- View the page source and search for
script.js?siteId=to confirm the snippet is on the page. - Open the browser Network tab and check that
script.jsreturns200and thatPOSTrequests go to/api/track. - Disable ad blockers, or set up a proxy so the script loads from your own domain.
- See the script troubleshooting guide for other common causes.
Troubleshooting
- Snippet missing from the page source:
jekyll serveand a plainjekyll buildrun withjekyll.environmentset todevelopment, so the production guard removes the tag. Build withJEKYLL_ENV=productionand check that output. - Config changes not applied: Jekyll reads
_config.ymlonce at startup, so restartjekyll serveafter addingrybbit_site_id.
Next steps
- Track custom events such as signups, purchases and button clicks.
- Identify users to connect sessions to accounts.
- Proxy the script through your own domain to bypass ad blockers.
- Script attributes let you skip or mask URLs and tag events.