Analytics
Knowledge supports the integration of analytics scripts to monitor the usage of your documentation site.
Configuration
To add analytics to your site, configure the analytics
field in your knowledge.config.ts
file:
export default {
// ... other configurations
analytics: {
script: ''
},
// ... other configurations
} as KnowledgeConfig;
Usage Examples
Umami Analytics
analytics: {
script: ''
}
Google Analytics 4
analytics: {
script: `
`
}
Plausible Analytics
analytics: {
script: ''
}
How It Works
The script configured in the analytics.script
field will be automatically inserted into the <head>
of all pages generated by Knowledge. This ensures that the analytics code is loaded on all pages of your documentation site.
Privacy Considerations
When implementing analytics, consider:
- GDPR/CCPA Compliance: Make sure your analytics solution complies with data protection laws
- Transparency: Inform users about the use of analytics in your privacy policy
- Privacy-Friendly Analytics: Consider using solutions like Plausible or Umami that are more privacy-respectful
Disabling Analytics
To disable analytics, simply remove or comment out the analytics
field from your configuration file:
export default {
// ... other configurations
// analytics: {
// script: '...'
// },
// ... other configurations
} as KnowledgeConfig;