Feature Flags
Feature Flags let you control who sees a feature and when, enabling gradual rollouts, targeted deployments, and instant kill-switches for risky functionality.Overview
Feature Flags let you control who sees a feature and when. Use them to:- Gradually roll out changes (E.g 1% → 10% → 100%)
- Target cohorts, regions, platforms, or group accounts
- Kill-switch risky functionality instantly
- Serve variants for A/B/x tests and analyze results with Mixpanel Experiments
Key Concepts
- Flag Key — unique identifier for a flag used by SDKs
- Variant Assignment Key — the randomization bucket unit:
distinct_id(user),device_id, or a group key likeaccount_id - Variants — experience labels (e.g.,
control,A,B) - Variant Splits — allocation across variants (e.g., 90%/10%)
- Fallback Value — variant to use when an assignment is unavailable
- Sticky Variants — the same entity keeps the same variant over time
- Rollout Groups - the configuration determining which users are in the rollout
- Runtime Properties — request-time attributes (e.g., URL path, app version) used to target immediately
- Runtime Events — event-based targeting (e.g., user clicked button, completed purchase)
Types of Feature Flags
We support the following types of Flags:- Feature Gate: Toggle a feature on or off for targeted users or all users. Useful for phased or controlled rollout.
- Experiment: Deliver different variant experiences (e.g., layouts, flows, pricing) to a targeted group of users. Enables measuring and analyzing impact.
- Dynamic Config (Coming Soon): Configure features with flexible key-value pairs instead of just on/off. Pass JSON payloads to customize behavior or UI dynamically.
Setup Instructions
Choose Variant Assignment Key
Select the randomization bucket unit that best fits your use case:
- User
distinct_id— best for logged-in experiences across devices; a user sees a consistent experience across various sessions and devices - Device
device_id— best for pre-auth or acquisition flows; a device keeps a consistent variant between pre-auth and post-auth experiences - Group
group_id— target by account/org using a group key (e.g.,account_id). Values for group keys will need to be supplied to the Mixpanel feature flag SDK through thecontextparameter
Configure Variants
Set up your variants and their allocation:
- Define variant names (e.g.,
control,A,B) - Set variant split percentages (e.g., 10% of users in variant A, and 90% in variant B)
- Enable sticky variants to ensure continuity in the variant experience
Set Up Rollout Groups
Configure targeting for your feature flag:
- Target ‘All Users’ or specific cohorts based on user behavior or properties
- Set rollout percentage for each group
- Add runtime properties for immediate, per-request decisions (e.g., platform, country)
- Add runtime events to target users when they perform specific actions
Implementation Examples
JavaScript SDK
Python SDK
iOS (Swift) SDK
Runtime Targeting
Runtime targeting enables immediate, per-request decisions using two methods:Runtime Properties
Target users immediately based on device or platform properties:Runtime Events
Target users immediately when they perform specific actions:Performance & Reliability
Privacy
- EU & IN projects must initialize the SDK’s with the correct api host endpoints for their regions
- You should only send the context/runtime properties you need; avoid sensitive PII
Regions
Keep traffic within region by using the correct project & API hosts.Reliability
Mixpanel analytics downtime will result in suspended cohort membership refreshes, though feature flag variants will continue to be served.- When using sticky variants, the last available variant per user will be served
- In case of Feature flagging service downtime, your fallback variant will be served by the SDKs
Performance
The latency of Feature flags API responses is usually on the order of milliseconds.Testing Environment Best Practices
Use separate Mixpanel projects, which are connected to your different environments, to reduce risk and promote safety:- Dev Project — rapid iteration; permissive targeting
- Staging Project — mirrors prod cohorts; dry runs for promotion
- Prod Project — customer-facing
Recommended Workflow
Create in Dev
Create the flag in dev with a consistent Flag Key. Validate eligibility, variants, etc.
Governance & Permissions
Permissions
- Project Role — you need to have at least an “analyst” role to create and edit feature flags. “Consumer” roles can only view feature flags
- Feature Flag Permissions — You can manage share settings per flag. Only editors for a flag will have access to modify a flag generally