kapa.ai What is the best way to measure time spent on specific events?
The best way to measure time spent on specific events in Mixpanel is to use the event timing feature available in the SDKs. This involves marking the start of an action with a timing method (such as .time_event()
in JavaScript or .timeEvent()
in other SDKs), and then sending a .track()
call when the action completes. The elapsed time is automatically recorded in the "Duration" property of the event.**Example in JavaScript:**LBKS// Start timing the event mixpanel.time_event('Image Upload');LBKS// ...user performs the action...LBKS// Track the event, "Duration" will be set automatically mixpanel.track('Image Upload');LBKS
This approach is supported across Mixpanel SDKs, including JavaScript, iOS (Swift/Objective-C), Android, React Native, Flutter, and Unity. The "Duration" property will contain the time (in seconds) between the start and end of the event, allowing you to analyze how long users spend on specific actions in your reports. You can then aggregate or break down this property in Mixpanel reports to get insights such as average time spent per event or user Docs: Javascript SDK, Docs: Swift SDK, Docs: Android SDK.If you want to measure time spent per session (rather than per event), Mixpanel also provides a "Session Duration (seconds)" property on session events, which can be used for session-level analysis Docs: Sessions Use Cases.
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.
Let me check the knowledge base for you again. One moment! 📚
Based on the available knowledge sources, Mixpanel currently measures time spent on specific events primarily through the use of the "Duration" property, which is set when you use the timing methods in the SDKs (e.g., .time_event()
and .track()
). This property is then available for analysis in Mixpanel reports, allowing you to see metrics like average or total duration for an event Docs: Javascript SDK.For session-level analysis, Mixpanel provides the "Session Duration (Seconds)" property on session events, which can be used to analyze how long users spend in a session, but not specifically how long they spend on a particular event unless you instrument it with the SDK timing methods Docs: Sessions Use Cases.There is no information in the knowledge sources about plans to automatically calculate the duration between arbitrary events (such as "Video Watched" and the next event or session end) directly within Mixpanel reporting, without SDK instrumentation. The current approach requires explicit tracking of start and end points for the event you want to measure.If you want to analyze how long a user watched a video for, you need to instrument your events so that the "Duration" property is set, or otherwise calculate the difference between event timestamps outside of Mixpanel. The knowledge sources do not mention any built-in feature or upcoming plan to automate this calculation within Mixpanel’s reporting interface.If you need more advanced calculations (like time between any two arbitrary events), you may need to export your data and perform this analysis externally. I'm sorry, but there's no information about future plans to add this capability natively in Mixpanel reports at this time.
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.