Mixpanel Community Icon

Calculating Duration Between Two Events Using Timestamps

·
·

How to make insights that calculates the duration using timestamps between 2 distinct events (A & B) that share a common property and are linked with that value (e.g. filename). So Event B's timestamp minus Event A's timestamp to get the difference in time between both events?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Sean Y., 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

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    To calculate the duration between two distinct events (A & B) that share a common property value in Mixpanel, you can use Behavioral Properties in Insights. This feature allows you to analyze the time difference between related events.Here's how to approach this:

    Using Behavioral Properties

    Mixpanel's Behavioral Properties feature allows you to compute virtual properties based on user activity. For your specific use case of calculating time between two events that share a common property value (like filename), you'll want to use the "Aggregate Property per User" option.1. In Insights, click on the "Filter" section 2. Select "Behavioral Properties" 3. Choose "Aggregate Property per User" 4. Select your Event B (the later event) 5. Select the timestamp property 6. Choose an appropriate aggregation type (likely "Average" or "Sum") 7. Set up a filter to ensure you're only including events that have the matching property value (e.g., same filename value as Event A)Mixpanel Docs: Behavioral Properties

    Alternative Approach: Custom Properties

    If you need more flexibility, you can also use Custom Properties to calculate the time difference: 1. Create a custom property that borrows the timestamp from Event A 2. Create another custom property that calculates the difference between Event B's timestamp and the borrowed timestamp from Event AThis approach is particularly useful when merging events from different systems or when you want to join event properties within a product session.Mixpanel Docs: Custom Properties

    Time Measurement Considerations

    When working with time measurements in Mixpanel, remember that: - You can use the built-in "Duration" property if you're using the SDK's timing functions - For more complex time calculations between distinct events, behavioral properties or custom properties are more appropriate - Time calculations can be used in formulas for more advanced analysisIf you need more specific implementation details for your particular events and data structure, you might want to consult Mixpanel's support team as the exact approach can vary depending on how your events and properties are structured.

    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.