Frameworks
Docusaurus
Docusaurus analytics with Stickybeak starts by adding its script to your rendered pages; this guide shows you where it belongs and how to track page views, goals and purchase revenue. It is a lighter alternative to Google Analytics for Docusaurus, with live visitors, goals and revenue attribution in one script.
Add the script
Add it to the scripts option
Each object in
scriptsbecomes a<script>tag with those attributes:import type { Config } from "@docusaurus/types"; const config: Config = { title: "My docs", url: "https://docs.example.com", baseUrl: "/", scripts: [ { src: "https://app.usestickybeak.com/_cfw/s.js", defer: true, "data-site": "YOUR_SITE_ID", "data-domain": "example.com", }, ], // …the rest of your config }; export default config;If your docs live on a subdomain like
docs.example.com, you can still useexample.comas the domain: subdomains count towards it. Or add the docs as their own site.Build and deploy
docusaurus startruns onlocalhost, which isn't counted.
Only in production builds
docusaurus build sets NODE_ENV to production, so you can leave the tag out otherwise:
For production only, return the same scripts array when process.env.NODE_ENV === "production".
The headTags option works too, if you already use it for other tags. Use tagName: "script" and the same attributes.
Check it's working
Test the deployed site, then verify your install.
Track goals
Add data-goal in MDX. For component events, use the React helper. See Custom goals.
<a href="https://app.example.com/signup" data-goal="docs_signup_click" data-goal-page="getting_started">
Create your account
</a>
Track purchases
After confirming an order in the browser, send:
window.stickybeak?.("purchase", { revenue: 49, currency: "USD", order_id: "ORDER_ID" });
Use real values; see Revenue.
Page changes
New docs paths count; same-page headings do not. See Single-page apps.
If it isn't working
Check the production site ID and domain, then see Troubleshooting.