问题
We are trying to build a histogram of session length in a given time period. Currently, we have sess:start and sess:end events which contains the session id and user id. I am wondering what's the best way to compute this data? Can this be achieve using the funnel api?
回答1:
Have you checkout out the recipes section in Keen IO's docs? Here is an excerpt from the section on histogram recipes for Session Length that might be really helpful.
Excerpt
To create a histogram for session lengths, like the one shown above, you can run a count analysis on an event collection for completed sessions (e.g. session_end). Along the x-axis you’ll have segments of time lapsed in a session, and along the y-axis you’ll have the percentage of sessions that fit into a given session length cohort.
Note: this recipe incorporates the D3 histogram recipe, which is explained further in the documentation.
histogram('chart-1', {
segment_length: 60, // In seconds
data_points: 10, // i.e. There will be 10 bars on our chart
analysis_type: 'count',
query_parameters: {
event_collection: 'session_end',
timeframe: timeframe,
filters: []
}
});
More information
- Keen IO - Analytics for Developers
- Keen IO - Documentation
- Code excerpt: Keen IO - Recipes for Histograms
回答2:
Lots of good stuff behind the link that Stephanie posted.
One extra thing I'll venture is that putting an integer sess:length property in the sess:end event would make things easier. You'd have to keep the start time for each session somewhere in your database so that you can compute the difference for the sess:end event. But then you'd have the difference as a plain old number of seconds and can do any type of numerical analysis on it.
来源:https://stackoverflow.com/questions/26619758/create-a-histogram-of-session-length-in-a-given-time-period-using-keen-io