Is it possible to calculate time spent by user on a certain page something like page viewed duration?
Yes, Mixpanel offers a couple of ways to calculate time spent on a page:
1. Timing Events (SDK-level)
You can use the .time_event() method (JavaScript) or .timeEvent() (Android) to measure the duration between when a user lands on a page and when they leave. The elapsed time is automatically recorded as a "Duration" property on the tracked event.
JavaScript example:
// When user arrives on the page
mixpanel.time_event('Page Viewed');
// When user leaves the page
mixpanel.track('Page Viewed', { "page": "/pricing" });
// This will include a "Duration" property with the time spent in seconds2. Computed Properties โ Duration
Mixpanel also offers a Duration computed property, which calculates the time between two instances of the same event (e.g., consecutive Page View events). This works best for events that occur continuously during a session, such as Page View or Screen View. [Computed Properties]
3. Session Duration
If you're interested in overall time spent per session (rather than a specific page), Mixpanel automatically computes a "Session Duration (Seconds)" property on Session Start/End events. You can filter or break down by page URL to narrow it down. [Sessions Use Cases]
Recommendation: For page-level duration tracking, the timing events approach (option 1) gives you the most precise and explicit measurement per page visit.
โน๏ธย Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
