Hi folks! I hope you are doing well. I have a question regarding the update past event. For instance, we have an event to track payment. We have two different payment type that "renewal" and "new". In the past we do not set custom properties. But I know which user and when pushed that exact event. How can I set past event's custom event property? Thank you!
Hi Ilkan 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
To update past events in Mixpanel with custom properties, you'll need to use the import API rather than the standard tracking methods. The Mixpanel SDKs are designed for real-time tracking and don't support updating historical events directly. Here's how you can approach this:1. Use the /import API endpoint to import the updated events with the new custom properties. This API is specifically designed for importing historical data.2. For implementing this, Mixpanel recommends using either:
- The Python SDK's .import_data() function
- The mixpanel-utils module's import_events() functionBoth of these methods leverage the /import API for event ingestion, which allows you to import events that occurred more than 5 days in the past.Here's an example of how you might use the Python SDK to import updated events:LBKSfrom mixpanel import MixpanelLBKSmp = Mixpanel("YOUR_PROJECT_TOKEN")LBKS# Assuming you have a list of events to update events_to_update = [ { "event": "Payment", "properties": { "distinct_id": "user123", "time": 1609459200, # Unix timestamp of the original event "payment_type": "renewal" # New custom property } }, # ... more events ... ]LBKSmp.import_data(events_to_update)LBKS
Remember that when updating historical events:
- You need to include the original timestamp of the event
- Make sure to use the correct distinct_id for each user
- Include all the properties you want the event to have, not just the new onesFor more detailed information on importing historical events, you can refer to the Mixpanel documentation on importing historical events.Mixpanel Java SDK Documentation
Mixpanel Swift SDK Documentation
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.