We're running an experiment in MixPanel, and we use the Experiment Started event. The experiment should include all users who open the site and see the specific test text, and we're looking for hook clicks on the button containing the test. The problem is that not all hook clicks show as part of the test. Why is that, and how can we resolve it so that all hook clicks are a part of the test?
Hi Robert Š., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
The issue you're experiencing—where not all hook clicks are attributed as part of the experiment—likely stems from how and when the $experiment_started (Experiment Started) exposure event is being tracked.
Key points from Mixpanel documentation:
- The $experiment_started event should be sent only when a user is actually exposed to the experiment, i.e., when they see the specific test text, not just when they are assigned to a variant or open the site. This ensures that only users who truly experience the test are included in the experiment analysis.
- If the exposure event is not sent at the correct moment (e.g., it is sent too early, too late, or not at all for some users), subsequent events like hook clicks may not be attributed to the experiment. Mixpanel attributes user actions to a variant only after the exposure event is tracked for that user.
- The exposure event should be sent the first time a user is exposed to the experiment, and not for every session or page load. If a user is not exposed (does not see the test text), the exposure event should not be sent for them Experiments: Implementation for Experimentation.
Why are some hook clicks not part of the test?
- If a user clicks the hook button before the $experiment_started event is fired (i.e., before Mixpanel knows they are exposed to the experiment), those clicks will not be attributed to the experiment.
- If the exposure event is not reliably triggered for all users who see the test text, some users' actions will not be counted as part of the experiment.
How to resolve this:
1. Ensure the $experiment_started event is fired exactly when the user sees the test text—not before, not after. This should be the moment of exposure.
2. Verify that the event is sent for every user who sees the test text. Double-check your implementation to ensure there are no conditions or timing issues that could prevent the event from firing.
3. Do not send the exposure event for users who do not see the test text. This keeps your experiment sample accurate.
4. Check for race conditions: Make sure the $experiment_started event is sent before any possible hook click event can be triggered, so that Mixpanel can correctly attribute subsequent events to the experiment variant.
Example implementation:
```
// When the test text is rendered and visible to the user mixpanel.track('$experiment_started', { 'Experiment name': 'Your Experiment Name', 'Variant name': 'Test' });
// Now, any hook click will be attributed to the experiment
LBKS**Summary:**
The most common cause for your issue is that the exposure event is not being sent at the right time for all users. Review your implementation to ensure the $experiment_started event is reliably and immediately sent when the user sees the test text. This will ensure all subsequent hook clicks are attributed to the experiment as intended Experiments: Implementation for Experimentation.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
