Skip to main content

Overview

Fern allows you to add custom JavaScript to your documentation site through the docs.yml configuration file. This enables you to include the CustomerOS tracker across all pages.

Installation

Get the JavaScript snippet from the CustomerOS app - it’s specific to your domain so that you aren’t blocked by adblockers and privacy modes.
  1. In your Fern project, create a JavaScript file for the tracker:
    mkdir -p fern/js
    touch fern/js/customeros-tracker.js
    
  2. Open fern/js/customeros-tracker.js and paste the JavaScript code from the CustomerOS app
  3. Update your docs.yml file to include the custom JavaScript:
    js:
        - path: ./js/customeros-tracker.js
    
  4. Commit and push your changes:
    git add fern/js/customeros-tracker.js fern/docs.yml
    git commit -m "Add CustomerOS tracker"
    git push
    
  5. Deploy your Fern documentation
The tracker will now be included on all pages of your documentation.
Make sure the path in your docs.yml correctly points to your JavaScript file location.

Verifying Installation

After deploying your site:
  1. Visit your Fern documentation
  2. Open your browser’s developer console (F12 or right-click → Inspect)
  3. Check the Network tab for a request to your tracker domain
  4. Look for successful 200s and 202s from the tracker subdomain
  5. Check the Console tab for any errors
You should see page views appearing in your CustomerOS dashboard within a few minutes.

Troubleshooting

If the tracker isn’t working:
  • Ensure the JavaScript file path in docs.yml is correct
  • Check that you’ve deployed the changes to your Fern site
  • Verify that your tracker domain is correct and accessible
  • Check the browser console for any JavaScript errors
For more help, see our Troubleshooting guide.

Additional Resources

I