Mixpanel is an event-centric analytics tool that tracks user events rather than automatically capturing data. Integrating Mixpanel with your Document360 knowledge base lets you analyze how readers interact with your content, which articles drive engagement, where they drop off, and how effective your site is overall.
Before you begin
- You need a Mixpanel account.
- You need your Mixpanel Project token, available in Mixpanel under Settings > Project settings > Project token.
Configuration options
When adding the Mixpanel integration, you can choose between two configuration types:
- Basic configuration: standard setup that automatically tracks page views after you enter your Mixpanel Project token. Use this for a quick setup with minimal effort.
- Custom configuration: advanced setup that requires loading and initializing the Mixpanel library manually. Use this when you want to track specific events beyond page views, such as button clicks or form submissions.
How to set up Mixpanel
Basic configuration
- In the Document360 portal, navigate to Connections () > Integrations () in the left navigation bar.
- Select Mixpanel from the list of integrations and click Add. The Add new integration dialog appears.
- Select the Basic configuration option.
- Enter a Description for this integration.
- Enter your Mixpanel Project token in the Mixpanel ID field. For details on where to find your token, see the Mixpanel installation guide.
- Optionally, expand Code inclusion/exclusion conditions to apply the code based on IP address, Workspace, or Language.
- Click Add.
Your knowledge base will now send page view data to Mixpanel.
If you want to track additional events such as button clicks or form submissions, use the Custom configuration option instead.
Custom configuration
Use Custom configuration to set up an advanced Mixpanel integration. This option lets you add JavaScript code directly in the configuration panel and customize event tracking based on your needs.
- In the Document360 portal, navigate to Connections () > Integrations () in the left navigation bar.
- Select Mixpanel from the list of integrations and click Add. The Add new integration panel appears.
- Select the Custom configuration option.
- Enter a Description for this integration.
- Paste your JavaScript snippet into the code field. See the examples below.
- Optionally, expand Code inclusion/exclusion conditions to apply the code based on IP address, Workspace, or Language.
- Click Add.
Custom configuration does not load Mixpanel automatically. You must first include the Mixpanel library and initialize it with your Mixpanel Project token.
Example: Load and initialize Mixpanel
Replace YOUR_PROJECT_TOKEN with your actual Mixpanel Project token from Mixpanel's Project settings.
<script>
(function(f,b){
if(!b.__SV){
var e,g,i,h;window.mixpanel=b;b._i=[];
b.init=function(e,f,c){function g(a,d){var b=d.split(".");
2==b.length&&(a=a[b[0]],d=b[1]);
a[d]=function(){a.push([d].concat(Array.prototype.slice.call(arguments,0)))}}
var a=b;"undefined"!==typeof c?a=b[c]=[]:c="mixpanel";
a.people=a.people||[];a.toString=function(a){var d="mixpanel";
"mixpanel"!==c&&(d+="."+c);a||(d+=" (stub)");return d};
a.people.toString=function(){return a.toString(1)+".people (stub)"};
i="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set set_once union unset toString reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking get_group".split(" ");
for(h=0;h<i.length;h++)g(a,i[h]);
b._i.push([e,f,c])
};
b.__SV=1.2;
e=f.createElement("script");
e.type="text/javascript";e.async=!0;
e.src="https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
g=f.getElementsByTagName("script")[0];
g.parentNode.insertBefore(e,g)
}
})(document, window.mixpanel || []);
mixpanel.init("YOUR_PROJECT_TOKEN");
</script>
Example: Page view tracking
<script>
mixpanel.track("Page View", {
"Page URL": window.location.href,
"Page Title": document.title,
"Referrer": document.referrer || ""
});
</script>
You can rename "Page View" to another event name such as "Article Viewed" or "Category Opened" depending on what you want to track.
Example: Button click tracking
Replace yourButtonId with the actual ID of the button you want to track, and update "Your Button Label" with a meaningful label. For example, if you are tracking a button labelled "Subscribe", use "subscribeButton" and "Subscribe".
<script>
document.getElementById("yourButtonId")
.addEventListener("click", function() {
mixpanel.track("Button Click", {
"Button Name": "Your Button Label",
"Page URL": window.location.href
});
});
</script>
The examples above cover the most common use cases. To track other event types such as form submissions, video plays, or scroll depth, refer to the Mixpanel JavaScript SDK documentation for a complete list of methods and advanced tracking patterns.
Verify the configuration
If no data appears in Mixpanel after setup, work through the following checks:
Confirm your token
Make sure you entered the Mixpanel Project token and not the Project ID or API secret.
Check the page source
- Open your knowledge base site in a browser.
- Right-click anywhere on the page and select View page source (shortcut:
Ctrl + Uon Windows/Linux,⌘+ Option+ Uon Mac). - Press
Ctrl + F/⌘ + Fand search formixpanel. If you do not find it, the Mixpanel integration script has not been injected.
Check the Network tab
- Open your knowledge base site in a browser.
- Press F12 (Windows/Linux) or
⌘ + Option + I(Mac) to open Developer Tools. - Go to the Network tab.
- In the filter box, type
api.mixpanel.com. - Reload the page or perform an action such as viewing an article. If you see requests to
api.mixpanel.com, events are being sent. If no requests appear, the Mixpanel library is not loading or events are being blocked.
Rule out blockers
Check for ad blockers, cookie consent banners, or restrictive Content Security Policies (CSP). These can prevent Mixpanel from loading or sending data.
Always test in an incognito or private browser window. This ensures you are loading the latest published scripts and avoids issues caused by browser caching.
Workaround using Custom HTML
If the Mixpanel integration script does not load correctly through the native integration, you can add it as a Custom HTML integration instead.
- In the Document360 portal, navigate to Connections () > Integrations () in the left navigation bar.
- Select Custom HTML from the list of integrations and click Add. The Add new integration panel appears.
- Paste the Mixpanel library snippet (see "Load and initialize Mixpanel" above).
- Add your custom event tracking code below the initialization snippet.
- Click Add and test again in Mixpanel.
Best practices
- Use Basic configuration unless you need custom event tracking. For most knowledge bases, entering the Project token under Basic configuration is enough to start tracking page views.
- Always initialize the Mixpanel library before calling tracking functions. In Custom configuration, paste the full library initialization snippet first, then add your event tracking code below it.
- Test in an incognito window after saving. Browser caching can cause stale scripts to run, which makes it look like changes haven't taken effect.
- Use Code inclusion/exclusion conditions to exclude internal traffic. Add your office IP address as an exclusion to prevent team visits from skewing your analytics data.
- Rename events to match your naming convention. Mixpanel event names are case-sensitive and appear as-is in your dashboard. Use consistent, descriptive names like "Article Viewed" rather than "Page View" to make your data easier to read.
FAQ
What is the difference between Basic and Custom configuration?
Basic configuration automatically tracks page views after you enter your Mixpanel Project token. Custom configuration requires you to manually load the Mixpanel library and write JavaScript to track specific events. Use Basic for a quick setup, and Custom when you need to track events beyond page views.
Where do I find my Mixpanel Project token?
In Mixpanel, go to Settings > Project settings > Project token. Make sure you copy the Project token and not the Project ID or API secret, as these are different values.
Why is no data appearing in Mixpanel after I set up the integration?
Check that you entered the correct Project token, verify the Mixpanel script is injected by searching for "mixpanel" in the page source, and check the Network tab in Developer Tools for requests to api.mixpanel.com. Ad blockers, cookie consent banners, or Content Security Policies may also block the script from running. See the Verify the configuration section for step-by-step checks.
Can I track events other than page views?
Yes. Use the Custom configuration option and add JavaScript event tracking code for button clicks, form submissions, video plays, or any other interaction. See the code examples in this article, and refer to the Mixpanel JavaScript SDK documentation for advanced patterns.
Can I limit which workspaces or languages Mixpanel tracks?
Yes. When adding or editing the Mixpanel integration, expand the Code inclusion/exclusion conditions section and add conditions based on IP address, Workspace, or Language. See Code inclusion and exclusion conditions for full details.