Overview
Docusaurus allows you to add custom scripts to your documentation site through thedocusaurus.config.js configuration file. Scripts are automatically included in the <head> section of every page.
Installation
Get the HTML Snippet from the CustomerOS app to add to your website. It is specific to your domain so that you aren’t blocked by adblockers and privacy modes.Adding the Tracker Script
- 
In your Docusaurus project’s srcdirectory, create a new JavaScript file:
- 
Open src/customeros-tracker.jsand paste the JavaScript code from the CustomerOS app
- 
Open your docusaurus.config.jsfile and add the script to thescriptsarray:
- 
Save the file and restart your development server:
- 
Build and deploy your site:
The JavaScript file should be placed in the 
src directory, and the path in
scripts should start with /.Alternative: Page-Specific Installation
If you only want to track specific pages, you can create a custom component that includes the tracker script:- Create a component file (e.g., src/components/CustomerOSTracker.js):
- Import and use the component in any page where you want tracking:
Verifying Installation
After building and deploying your site:- Visit your Docusaurus documentation
- Open your browser’s developer console (F12 or right-click → Inspect)
- Check the Network tab for a request to your tracker domain
- Look for successful 200s and 202s from the tracker subdomain
- Check the Console tab for any errors
Troubleshooting
If the tracker isn’t working:- Ensure the JavaScript file is in the srcdirectory
- Check that the script path is correctly added to docusaurus.config.jsin thescriptsarray
- Verify the path starts with /(e.g.,/src/customeros-tracker.js)
- Ensure you’ve restarted your development server after making changes
- Check that you’ve built and deployed your site (changes don’t appear in development mode)
- Verify that your tracker domain is correct and accessible
- Check the browser console for any JavaScript errors