Zola
Step-by-step guide to add OnyxMetric cookieless analytics to your Zola site and start tracking visitors
Zola pages extend a base Tera template, normally templates/base.html, so the tag belongs in that file's <head>. The [extra] table in config.toml is a good home for the site ID.
Copy your tracking snippet
In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>YOUR_SITE_ID is the numeric ID of your site.
Add the snippet to Zola
-
Add the ID to
config.toml:config.toml [extra] onyxmetric_site_id = "YOUR_SITE_ID" -
Edit
templates/base.html. Theconfig.modecheck excludeszola serve, so local work is not tracked:templates/base.html <head> ... {% if config.mode == "build" %} <script src="https://app.onyxmetric.com/api/script.js?siteId={{ config.extra.onyxmetric_site_id }}" async></script> {% endif %} </head>If a theme provides
base.html, copy it fromthemes/<theme>/templates/into your owntemplates/first. A file with the same name in your site overrides the theme's. -
Build and deploy
public/:zola build
Check that it works
Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.
If nothing arrives:
- View the page source and search for
script.js?siteId=to confirm the tag is present. - In the browser's Network tab, check that
script.jsreturns200and that requests go to/api/track. - Turn off ad blockers, or proxy the script through your own domain.
- Read script troubleshooting for other causes.
Troubleshooting
- Tag missing locally:
zola servesetsconfig.modetoserve. Check the output ofzola build. config.modeundefined: older Zola releases lack it. Upgrade, or remove theifand accept local pageviews.- Some pages without the tag: templates that do not extend
base.html(such as a custom404.html) need the tag separately.
Next steps
- Track custom events such as signups, purchases, and clicks.
- Identify users to tie sessions to accounts.
- Proxy the script through your own domain to get past ad blockers.
- Script attributes let you skip or mask URLs and tag events.