GitBook
Add Rybbit analytics to your GitBook docs
GitBook does not let you add custom scripts to a published site, and its integration platform does not let third parties inject them either. This page explains what that means and what your options are.
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 GitBook
There is currently no supported way to load the Rybbit snippet on a GitBook-hosted site. The old Custom scripts → Head setting was removed, and GitBook's integration scopes reserve site:script:inject for GitBook's own integrations: "Building integrations that inject JavaScript into a site or space is not possible at this time."
Your options:
- Use GitBook's built-in analytics. The Insights section in the GitBook app reports page views and search terms for published sites without any script.
- Wait for a native integration. A Rybbit integration would need GitBook to build or approve it. Ask GitBook support for it, and watch the Rybbit roadmap.
- Host the docs elsewhere. Docusaurus, Mintlify, VitePress, Starlight and Fumadocs all take the snippet directly, and GitBook can export a space as Markdown to migrate.
The rest of your site (marketing pages, app, blog) is unaffected: add the snippet there as usual so traffic from the docs is still attributed by referrer.
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.
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.