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.
Add the script in docusaurus.config.js:
js
export default {
// …
scripts: [
{
src: 'https://privatusanalytics.com/js/pa.js',
defer: true,
'data-site': 'pa_YOURSITEID',
},
],
}
Docusaurus is a single-page app after the first load. The tracker follows
its history.pushState navigations automatically.
Track searches and feedback#
Docs sites often want to know what people search for and whether a page helped. Track those as events (never the raw text of free-form input if it could contain personal data):
js
window.privatus?.track('Docs feedback', { helpful: true })