Integration Guides

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

  1. Add your site ID to _config.yml. rybbit_instance_url is only needed if you self-host:

    _config.yml
    rybbit_site_id: "YOUR_SITE_ID"
    rybbit_instance_url: "https://app.rybbit.io"
  2. 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.environment check keeps the script out of local jekyll serve builds; the site.rybbit_site_id check keeps it out of builds with no ID configured.

  3. 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:

_layouts/default.html
<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 build

GitHub 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.js returns 200 and that POST requests 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 serve and a plain jekyll build run with jekyll.environment set to development, so the production guard removes the tag. Build with JEKYLL_ENV=production and check that output.
  • Config changes not applied: Jekyll reads _config.yml once at startup, so restart jekyll serve after adding rybbit_site_id.

Next steps

On this page