Mixpanel
Add Mixpanel to your Docs
To add Mixpanel to your Docs, you need to create a custom JavaScript file and configure it in your docs.yml
file using your Mixpanel project token.
Get your Mixpanel Project Token
- Log in to your Mixpanel account.
- Navigate to the project you want to track.
- Go to Settings > Project Settings.
- Copy your Project Token from the project details.
Integration Steps
-
Create a scripts folder: Under your
fern
directory, create ascripts
folder if it doesn’t already exist. -
Create the Mixpanel script: In the
scripts
folder, create a file namedmixpanel.js
. -
Add the Mixpanel tracking code: In your
mixpanel.js
file, add the following script (replaceYOUR_PROJECT_TOKEN
with your actual project token):
- Configure your docs.yml: In your
docs.yml
file, add the JavaScript file configuration:
Security Considerations
Since Mixpanel tracking is implemented using client-side JavaScript, your project token will be visible in the browser’s source code. This is normal and expected behavior for client-side analytics implementations. Mixpanel project tokens are designed to be publicly visible and are safe to expose on the client side.
Testing Your Integration
-
Start your development server: Run
fern docs dev
to build and start your Fern docs locally (typically onhttp://localhost:3000
). -
Verify script loading: Open your browser’s developer tools and check the Console and Network tabs to confirm the Mixpanel script is loading correctly.
-
Test event tracking: Navigate through your docs site and verify that events are being tracked.
-
Check Mixpanel dashboard: Go to your Mixpanel project dashboard to verify that events are being received correctly.
Additional Resources
For more information on Mixpanel’s JavaScript SDK and advanced configuration options, visit the Mixpanel JavaScript SDK documentation.