Install Linqry on Docusaurus
To add Linqry to a Docusaurus site, add the tracker to the `scripts` array in `docusaurus.config.js` with your site ID as `data-*` attributes. Docusaurus inserts it into the `<head>` of every page, and navigations between docs are recorded as page views automatically.
Updated · 2 min read
Install with the scripts config
- Add your docs domain to Linqry
Start a free trial and add the domain your docs are served from. If the docs live on a subdomain of your main site (say
docs.example.com), you can addexample.cominstead and track both in one Linqry site, because subdomains of the registered domain are accepted. - Add the tracker to docusaurus.config.js
Each object in
scriptsbecomes a<script>tag in the<head>. Onlysrcis required, and any other attribute with a string or boolean value is passed through. Docusaurus notes these scripts are render-blocking unless you setdeferorasync, so keepdefer: true.// docusaurus.config.js export default { // ... scripts: [ { src: "https://linqry.com/t.js", defer: true, "data-website-id": "YOUR_SITE_ID", "data-domain": "yourdomain.com", }, ], }; - Build, deploy and check Realtime
Deploy the site, open a few doc pages and use the sidebar to move around. Realtime in Linqry shows each page as a
pageviewin the live event stream.
Optional: add the queue stub with a small plugin
The scripts and headTags options don't take inline script content, so the config above leaves out the snippet's first line, the queue stub. For most docs sites that's fine: page views and outbound clicks are automatic, and data-linqry-event attributes work without it. You only need the stub if your own code calls window.linqry early, before the tracker has loaded. A local plugin can inject both tags, in order, with the injectHtmlTags lifecycle method:
// docusaurus.config.js
export default {
// ...
plugins: [
() => ({
name: "linqry-analytics",
injectHtmlTags() {
return {
headTags: [
{ tagName: "script", innerHTML: "window.linqry=window.linqry||function(){(window.linqry.q=window.linqry.q||[]).push(arguments)}" },
{
tagName: "script",
attributes: {
src: "https://linqry.com/t.js",
defer: true,
"data-website-id": "YOUR_SITE_ID",
"data-domain": "yourdomain.com",
},
},
],
};
},
}),
],
};Use either the plugin or the scripts entry, not both, or the tracker loads twice.
Client-side navigation
A built Docusaurus site is static HTML that becomes a single-page app once it loads, so clicking a sidebar link changes the URL with the History API instead of loading a new page. The tracker wraps history.pushState and replaceState and listens for popstate, which means every doc a visitor opens is a page view, with time on page reported as they move on. Jumping to a heading changes only the #hash, which isn't counted as a new page; leave data-hash-routing off.
What's useful for a docs site
- Top pages, entry pages and exit pages show which docs people land on, which they read most and where they leave.
- Outbound clicks to GitHub, package registries or your app are recorded automatically as
outboundevents. - Custom events for things like a copied install command: put
data-linqry-event="install-command-copied"on the element in a swizzled component or MDX. See custom events. - Referrers and UTM parameters show which blog posts, newsletters or campaigns send readers to the docs.
If you'd like the docs stats to be public, Linqry can share a read-only dashboard by link or embed; see sharing.
Exclude your own visits
npm start serves on localhost, which Linqry ignores. On the live site, run this once in your browser console:
localStorage.setItem('linqry_ignore', 'true')Troubleshooting
- Nothing recorded? View the source of a built page and check the tracker tag carries
data-website-id. A typo in the quoted attribute names is the usual cause. - Versioned or localized docs on other hostnames? Add those hostnames under Additional hosts in site Settings.
- Testing with an ad blocker? Some block analytics scripts; use a clean browser profile.
Frequently asked questions
Can I use Linqry alongside the Docusaurus Google Analytics plugin?
Yes. They don't interact. Many teams run both while comparing numbers, then remove one; expect the counts to differ because the two tools identify visitors differently.
Is there a Docusaurus plugin package for Linqry?
No. The scripts entry, or the small local plugin above, is the whole integration.
Sources
- Docusaurus: docusaurus.config.js (scripts, headTags) (checked Nov 9, 2026)
- Docusaurus: Plugin lifecycle APIs (injectHtmlTags) (checked Nov 9, 2026)
Related
Paste the snippet into index.html in a Vite or other React SPA. React Router navigations are tracked as page views.
Send events from JavaScript or plain HTML attributes — plus the events Linqry records for you automatically.
Public read-only dashboards behind a revocable token, and five embeddable widgets for your own pages.
Linqry shows a publisher which articles get read, where readers come from and which posts lead to newsletter signups or sales, without setting cookies. Here's how bloggers and small editorial teams use it, and where a different tool fits better.
Start measuring your Docusaurus site
No card required · 30-day trial · No cookies