GitBook
Add OnyxMetric analytics to your GitBook docs
GitBook does not allow custom scripts on published sites, and its integration platform does not let third parties inject them. Here is what that means for you and what to do instead.
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 GitBook
There is currently no supported way to load the OnyxMetric tag on a site hosted by GitBook. The older Custom scripts setting is gone, and GitBook's integration scopes do not permit scripts from third parties.
Your options:
- Use GitBook's own analytics. The Insights section of the GitBook app reports page views and search terms for published sites, with no script.
- Ask GitBook. A native OnyxMetric integration would need GitBook to build or approve it, so a request to their support is the way to push for one.
- Host the docs elsewhere. Docusaurus, Mintlify, VitePress, Starlight, and Fumadocs all accept the tag.
The rest of your presence (marketing pages, app, blog) is unaffected. Add the tag there as usual, so traffic arriving from the docs is still credited by referrer.
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.
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.