how to create custom property: duration since the event occur. For example, 1 hour.
Hi Yanisa 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
To create a custom property that calculates the duration since an event occurred, you can use Mixpanel's Custom Properties feature. Here's how you can do it:1. Navigate to the Custom Properties section in Mixpanel.
2. Click the plus button to create a new custom property.
3. In the formula bar, you can use the TODAY()
function to calculate the difference between a date property and the current date/time.Here's an example of how you might define this custom property:LBKSfloor((TODAY() - .event_date) / 3600)LBKS
This formula calculates the number of hours since the event occurred. It subtracts the event date from the current date (using TODAY()
), then divides by 3600 (the number of seconds in an hour) to convert the result to hours. The floor()
function rounds down to the nearest integer.You can adjust the formula based on your specific needs. For example, if you want to calculate days instead of hours, you could divide by 86400 (the number of seconds in a day) instead of 3600.Remember that custom properties are calculated on the fly when you use them in reports, so they don't affect your underlying data.For more detailed information on creating custom properties, you can refer to the Custom Properties 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.
Let me check the knowledge base for you again. One moment! ๐
To refer to the date and time of an event in a custom property formula in Mixpanel, you can use the .event_date
syntax. This represents the timestamp of the event.Here's an example of how you might use it in a custom property formula:LBKSfloor((TODAY() - .event_date) / 86400)LBKS
In this example, .event_date
refers to the timestamp of the event. The formula calculates the number of days between the event date and the current date.It's important to note that .event_date
is in the project's timezone, not necessarily UTC. The TODAY()
function also uses the project's timezone.For more detailed information on using date and time in custom properties, you can refer to the Custom Properties documentation. This documentation provides more examples and explanations on how to work with dates and times in custom property formulas.
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.
Let me check the knowledge base for you again. One moment! ๐
The syntax you've provided is not entirely correct for Mixpanel's custom property formulas. Let me help you adjust it to the correct format:LBKSif( (TODAY() - .time) / 3600 > = 1, "Expire", "Active" )LBKS
Here's an explanation of the changes:1. In Mixpanel's custom property formulas, you don't need to use the @โ"""{"label":"Time","propertyDefaultType":"datetime","resourceType":"event","type":"datetime","value":"$time"}"""@โ
syntax. Instead, you can directly refer to the event property using a dot notation.2. If you want to refer to the event's timestamp, you should use .event_date
instead of .time
. However, if you have a custom property named "time" that you want to use, you can keep it as .time
.3. The IF
function in Mixpanel's formula language is lowercase, so it should be if
.This formula will return "Expire" if the event occurred 1 hour or more ago, and "Active" otherwise.For more information on creating custom properties and using the correct syntax, you can refer to the Custom Properties documentation.Remember that custom properties are calculated on the fly when you use them in reports, so you can adjust and test the formula as needed without affecting your underlying data.
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.
Let me check the knowledge base for you again. One moment! ๐
I apologize for the confusion. If you can't find .event_date
in your console, it's likely because Mixpanel uses a different property name for the event timestamp. Let's clarify this:In Mixpanel, the default property for the event timestamp is actually $time
, not .event_date
. I made a mistake in my previous explanation. Here's the correct information:To refer to the timestamp of an event in a custom property formula, you should use $time
instead of .event_date
. So, the correct syntax for your custom property formula would be:LBKSif( (TODAY() - $time) / 3600 > = 1, "Expire", "Active" )LBKS
This formula uses $time
, which is a reserved event property in Mixpanel. According to the documentation, $time
is described as:"A unix time epoch that is used to determine the time of an event. If no time property is provided, we will use the time when the event arrives at our servers."I apologize for the earlier confusion. Thank you for bringing this to my attention, as it allows me to provide you with the correct information.
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.