Dokumentation
Bläddra i dokumentationen

Add Privatus Analytics to Docusaurus

Add privacy-friendly analytics to a Docusaurus docs site with the scripts config in docusaurus.config.js, and track docs feedback as custom events.

Visa som Markdown

Add the script in docusaurus.config.js:

js
export default {
  // …
  scripts: [
    {
      src: 'https://privatusstats.com/js/pa.js',
      defer: true,
      'data-site': 'pa_YOURSITEID',
      'data-modules': 'engage,auto,vitals,clicks,ask',
    },
  ],
}

Docusaurus is a single-page app after the first load. The tracker follows its history.pushState navigations automatically.

Track feedback#

Docs sites often want to know whether a page helped. Track that as an event (never send the raw text of free-form input, which could contain personal data):

js
window.privatus?.track('Docs feedback', { helpful: true })