Mintlify
Add OnyxMetric analytics to your Mintlify docs
Mintlify loads every .js file in your docs content directory on every page, so the tag goes into a tiny script that injects it.
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 Mintlify
Create a JavaScript file in the content directory, beside docs.json and your .mdx pages:
(function () {
var el = document.createElement("script");
el.src = "https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID";
el.async = true;
document.head.appendChild(el);
})();Commit and deploy. Mintlify finds the file by itself, so nothing needs registering in docs.json. Mintlify's custom scripts page covers the details.
To set script attributes such as skip patterns, apply them to the element before appending it:
el.setAttribute("data-skip-patterns", JSON.stringify(["/internal/**"]));Mintlify sites are single-page apps. OnyxMetric records client-side navigation as pageviews, so no extra code is needed.
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.
Track custom events
Mintlify pages are MDX, so handlers can be inline:
<button
onClick={() => window.onyx?.event("download_clicked", { file: "getting-started.pdf" })}
>
Download guide
</button>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.