Mixpanel Community Icon

Handling Payment Events for Accurate Data Analysis

·
·

Hi everyone, I have a question. I want to create an event called “Payment” with three properties: amount and type_action, which includes (add payment, delete payment, edit payment). This event will be triggered from the backend when the user adds, deletes, or edits a payment. My problem is with the amount property. For example, if a user adds 7K, then edits it to 4K, and I want to analyze the data using a line chart to see the total amount, how can I make sure I’m only summing the final (correct) amount? In this case, I want the total to be 4K, not 7K + 4K = 11K.

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

    Hi Anhar S., 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 solve your issue with tracking payment amounts correctly in Mixpanel, I recommend using custom properties to ensure you're only counting the final amount in your analysis.

    Understanding Your Use Case

    You're tracking a "Payment" event with properties including "amount" and "type_action" (add/delete/edit). Your challenge is that when analyzing total amounts, you don't want to double-count when a payment is edited.

    Solution: Use Custom Properties

    Mixpanel's custom properties feature can help you calculate the correct amount by filtering based on the action type. Here's how: 1. Track your events as planned: Continue sending your "Payment" events with "amount" and "type_action" properties.2. Create a custom property that only counts the final amount: - In your report, click the plus button next to the search bar and select "Event Property" - Create a formula that only counts amounts for specific action typesFor example, you could create a custom property called "Final Amount" with a formula that only includes amounts where the action is "add payment" or "edit payment" (and excludes the original amount that was later edited).Custom Properties documentation explains how you can create these calculated properties on the fly.

    Alternative Approach: Use Aggregate Property Measurements

    When creating your analysis in Insights, you can: 1. Use the "Aggregate Property" measurement type instead of counting events 2. Select "Sum" as the aggregation method for your "amount" property 3. Add a filter for "type_action" to exclude certain actions or only include final actionsAggregate Property documentation shows how to use this measurement type.

    Best Practice for Your Event Structure

    Consider if your current event structure is optimal. According to Mixpanel's best practices: > "Keep Events as Actions... Events should neither be too broad nor too specific, and should be defined at the level of how you plan to analyze the user's action or behavior." Event Best PracticesYou might consider tracking separate events like "Payment Added", "Payment Edited", and "Payment Deleted" with the amount property on each, which could make analysis clearer.If you're on a Growth or Enterprise plan, you can save your custom properties for reuse across reports, making your analysis more consistent.

    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.