Mixpanel
Overview:
Mixpanel is a powerful analytics platform that helps you understand user behavior across web and mobile. It automatically tracks user interactions and provides deep insights into customer journeys, retention, and engagement patterns.
What This Integration Achieves:
This integration allows you to use Mixpanel-identified users and cohorts for VWO feature flag targeting. By importing user cohorts from Mixpanel into VWO, you can roll out or test features for specific segments (e.g., Power Users, Premium users, At-Risk users) and personalize product experiences based on actual user behavior tracked in Mixpanel.
Key Benefits:
- Segment-based targeting: Run feature experiments only for specific Mixpanel cohorts.
- Personalized rollouts: Deliver variations tailored to user properties (e.g., plan, region, engagement level, lifecycle stage).
- Cohort-driven A/B testing: Combine Mixpanel's behavioral analytics with VWO's experimentation engine.
- Data-driven decisions: Leverage Mixpanel's rich user behavior data for more effective feature rollouts.
Step 1: Enabling the VWO-Mixpanel Integration for your VWO Account:
To enable the VWO-Mixpanel integration for your VWO account:
- From the main menu of your VWO dashboard, go to Configurations > Integrations.
- Click on the Mixpanel integration and enable it by switching on the toggle. Once enabled, the Mixpanel screen within the VWO’s Integration section looks like this:
- You will be auto-navigated to the Config tab.
- Enable "Enable use of Mixpanel cohorts for visitor targeting".
- Click Save
- Copy/note the API key that VWO generates. You'll need this to configure Mixpanel.
Step 2 - Configure VWO as a Destination in Mixpanel:
- In Mixpanel, navigate to Integrations.
- Click Add a new integration, select VWO.
- Enter a name for the destination (e.g., “VWO Production”).
- Paste the API Key from the previous VWO step.
- For the user identification, make sure user profiles in Mixpanel have the $vwo_user_id property set (this must match the User ID in VWO).
- Click Save.
Step 3 - Sync Cohorts from Mixpanel to VWO:
-
In Mixpanel, go to Data Management > Cohorts.
-
Select an existing cohort or create a new one using Mixpanel’s segmentation builder.
-
Click on the cohort’s menu and choose Export to → VWO.
-
Choose the sync frequency:
- Dynamic Sync: Recommended. Syncs automatically every 2 hours, updates targeting as your cohort changes.
- One-Time Export: Only exports the current cohort list, no updates.
-
Click Sync.
Step 4 - Import & Activate Mixpanel Cohorts in VWO:
- Back in VWO, within the Mixpanel integration settings, click Add Cohort.
- Search for or select the Mixpanel cohort(s) you just synced.
- Click Add.
-
First sync may take up to 2 hours. Subsequent syncs are automatic (every 2 hours by default for dynamic sync).
-
Manual sync is available if required.
-
Step 5 - SDK Setup (Node.js Example)
Install and Initialize the VWO SDK
Install the official VWO FE Node SDK:
npm install vwo-fme-node-sdk
Setup Gateway Service:
Reference: VWO Gateway Service Doc
Initialize the SDK in your application with the VWO Gateway service:
Reference: SDK Initialization Doc
const { init } = require('vwo-fme-node-sdk');
const vwoClient = await init({
sdkKey: 'YOUR_SDK_KEY',
accountId: 'YOUR_ACCOUNT_ID',
gatewayService: {
url: 'YOUR_GATEWAY_SERVICE_URL'
}
});Note: The gatewayService is mandatory for Mixpanel integration because the SDK itself does not store your Mixpanel cohort data. When you evaluate a flag, the SDK uses the Gateway to check in real-time if the user belongs to the synced Mixpanel segment.
Step 6: Setting Up Pre-Segmentation for Mixpanel-Synced Segments
Once your Mixpanel segments are imported into VWO, configure pre-segmentation in your feature flag to target those users.
Configure Pre-Segmentation in the Feature Flag
-
Navigate to Feature Experimentation → Feature Flags in VWO.
-
Click Create Feature Flag (or open an existing one).
-
Add variables and variations as per your use case.
Example:
- Variable Name: Your_Variable_Name
- Type: Datatype
- Default Value: “Default value”
-
Choose a primary metric to measure conversions or engagement.
-
Go to the Rules tab → Click Create New Rollout Rule.
-
Under Audience, choose Custom Segment.
-
In Attribute, select Custom Variable.
-
Enter the identifier name used for targeting (e.g., vwo_user_id).
-
Choose Operator → In List.
-
Select the Attribute List corresponding to your Mixpanel segment (e.g., mixpanel_premium_users).
-
Save the rule and toggle ON the rollout rule.
Finally, copy the SDK Key; you’ll need it for SDK initialization.
Step 7: Implementing Mixpanel Segment Targeting in SDK
After configuring pre-segmentation in the VWO app, ensure your SDK passes the appropriate user context for evaluation. Let’s see an example of using Mixpanel cohorts in feature evaluation.
Once the SDK is installed, do the following
-
Set the Mixpanel user identifier (mapped to
$vwo_user_id) insidecustomVariableswhile creating the user context -
Pass this context to
getFlag()so VWO can evaluate the feature flag using Mixpanel cohort pre-segmentation.
let context = {
id: 'UserID', // Should match $vwo_user_id in Mixpanel
customVariables: {
//example custom variable
"vwo_user_id": "user_12345"
},
ipAddress: 'user_ip_Address',
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
};
const featureFlag = vwoClient.getFlag('featureFlag', context);
if (featureFlag.isEnabled()) {
console.log("Feature enabled for Mixpanel-segmented user");
} else {
console.log("User does not qualify for the Mixpanel cohort rollout");
}Explanation
- The key "vwo_user_id" must exactly match the identifier defined in your VWO pre-segmentation rule.
- If the value (e.g., user_12345) exists in the imported Mixpanel cohort list, the segmentation passes and the user qualifies.
- If not, the segmentation fails, and the rule remains disabled for that user.
Notes & Best Practices
- Ensure the custom variable key in your SDK context matches the one defined in VWO’s rule configuration.
- Only Mixpanel-identified users (with $vwo_user_id) from the synced cohort will pass the segmentation rule.
- If you have multiple Mixpanel cohorts, create separate rollout rules for each to maintain clear targeting logic.
- Always use dynamic sync to keep cohort data updated between Mixpanel and VWO.
Updated about 18 hours ago
