How do I get the average time to complete 2 key events in Mixpanel and allow that data to be collected via an API, how do I get the data in the first place that it can be accessed in one view on the board in Mixpanel?
Hi event, 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
To calculate the average time between two key events in Mixpanel and make that data accessible via API, you'll need to follow a few steps:
Collecting the Data
First, you need to ensure you're tracking the right events: 1. Start by implementing tracking for your two key events. As mentioned in the What to Track guide, you should focus on important events like sign-up and value moments.2. Make sure you're implementing server-side tracking for accuracy, as client-side tracking can lose 15-30% of events.
Creating the Average Time Calculation
To calculate the average time between events, you can use Mixpanel's Query API with the segmentation average endpoint: 1. Use the segmentation/average
endpoint which allows you to average an expression for events per unit time.2. The API call would look something like this: LBKSGET /segmentation/averageLBKS
With parameters including:
- project_id
: Your Mixpanel project ID
- event
: The event you're analyzing
- from_date
and to_date
: Your date range
- on
: The expression to average (in this case, the time difference between events)
- unit
: "hour" or "day" for time bucketingAs noted in the Query API documentation, this API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries.
Displaying on a Mixpanel Board
To display this data on a Mixpanel Board: 1. Create a custom report using the calculated average time metric 2. Add this report to your Board 3. You can use Mixpanel's templates as a starting point - the Company KPIs Dashboard Template allows you to create customizable reports with just a few clicks
Accessing via API
To access this data programmatically: 1. Use the Query API to retrieve the average time calculation 2. The API response will be in JSON format, which you can then use in your applicationsKeep in mind that depending on your Mixpanel plan, you may have different API access levels. The pricing page indicates that all plans include Ingestion & Export API access, but Query API access varies by plan.For more detailed implementation, you might want to explore Mixpanel's full API documentation or contact their support team for specific guidance tailored to your use case.
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.