Zola
Add Rybbit analytics to your Zola site
Zola pages extend a base Tera template, normally templates/base.html, so the snippet goes in that file's <head>. Keep the site ID in the [extra] section of config.toml, which every template can read as config.extra.
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 Zola
-
Add your site ID under
[extra]inconfig.toml.rybbit_instance_urlis only needed if you self-host:config.toml [extra] rybbit_site_id = "YOUR_SITE_ID" rybbit_instance_url = "https://app.rybbit.io" -
Open
templates/base.htmland add the tag inside<head>. Theconfig.modecheck keeps the script out ofzola serve, so local development is not tracked:templates/base.html <head> ... {% if config.mode == "build" %} <script src="{{ config.extra.rybbit_instance_url }}/api/script.js?siteId={{ config.extra.rybbit_site_id }}" defer></script> {% endif %} </head>If a theme owns
base.html, copy it fromthemes/<theme>/templates/base.htmlinto your owntemplates/directory first. A template in your site with the same name overrides the theme's copy, so the theme can be updated without losing the change. -
Build and deploy the generated
public/directory:zola build
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:
zola servesetsconfig.modetoserve, so the guard removes the tag. Check the output ofzola buildinstead. config.modeis not defined: older Zola releases do not expose it. Upgrade, or drop theifblock and accept local pageviews.- Pages without the tag: templates that do not
{% extends "base.html" %}(a custom404.html, or a section template that builds its own<head>) need the tag added separately.
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.