Docusaurus Integration
Add Ovyxa analytics to your Docusaurus documentation site using the headTags configuration or a custom client module.
Option 1: Using headTags (Recommended)
In your docusaurus.config.js, add the script to the headTags array:
docusaurus.config.js
module.exports = {
// ... other config
headTags: [
{
tagName: 'script',
attributes: {
defer: 'true',
'data-domain': 'yourdomain.com',
src: 'https://ovyxa.com/js/script.js',
},
},
],
}
Option 2: Using scripts Config
Alternatively, use the scripts array in your config:
docusaurus.config.js
module.exports = {
// ... other config
scripts: [
{
src: 'https://ovyxa.com/js/script.js',
defer: true,
'data-domain': 'yourdomain.com',
},
],
}
Tracking Custom Events
Create a custom client module to track documentation-specific events:
src/ovyxa.js
export function onRouteDidUpdate({ location }) {
// Track search usage
if (location.pathname === '/search') {
window.ovyxa?.('event', 'DocsSearch', {
props: { query: new URLSearchParams(location.search).get('q') },
})
}
}
Register it in your config:
docusaurus.config.js
module.exports = {
clientModules: ['./src/ovyxa.js'],
}
Or trigger events directly from any component:
window.ovyxa('event', 'FeedbackSubmit', { props: { page: '/docs/intro' } })
Cookieless Mode
Add data-cookieless to avoid cookie consent requirements:
docusaurus.config.js
headTags: [
{
tagName: 'script',
attributes: {
defer: 'true',
'data-domain': 'yourdomain.com',
'data-cookieless': 'true',
src: 'https://ovyxa.com/js/script.js',
},
},
],
Verify Installation
- Build and serve your site (
npm run build && npm run serve) - Visit the local or deployed site
- Open the browser Network tab and look for a request to
ovyxa.com/js/script.js - Check your Ovyxa dashboard to confirm pageviews are appearing