Users with the Consumer role cannot create new custom properties, but they can use custom properties created by other users.
Combine multiple properties, property values, functions, numeric operators, and comparison operators to create new properties that you can use in reports.
Create a Custom Property
Take existing properties (event properties or user profile properties) and use Excel-like formulas to transform those properties to create new properties.
Example use-cases include:
- Create custom buckets to group your numeric property values into
- Merge property values to fix implementation issues
- Add domain knowledge from existing data to make data more accessible
- Create new properties based on the values of different properties
- Compute the days between two date properties
- Modify numeric property values (round, ceiling, floor..)
- Extract terms from a URL using regex
Click Apply a formula to open the property builder. If you select this option under EVENT PROPERTIES you will only be able to select event properties to build your custom property from. If you select this option under USER PROFILE PROPERTIES you will only be able to select user profile properties.
Enter a name for the custom property. Select one or more properties to combine and transform. Each property you select is given a letter code beside it, which you can use in the Formula field to create a formula to customize the property.
When writing your formula, click Ctrl + Space to see a list of all the available functions and their descriptions. Click period (.) to search for event or user profile properties to add to the formula.
Click the Insert Example drop down to view a list of example formulas and insert them into the Formula field.
Custom properties are temporary for the current report by default if you click Apply. To save the custom property permanently for use in other reports and to make it usable by other project members, click Save as Custom Property. Clicking Save as Custom Property will take you to an additional window where you can set the Visibility and Editing controls.
Use the following functions in the Formula field to modify your custom property:
|Function Name||Definition||Syntax & Example|
|if||Evaluates if an expression is true or false.||
if(condition, value if true, value if false)
if(A=="Facebook" or A=="Twitter", "Social", A)
|ifs||Runs multiple checks and returns a value corresponding to the first true result. If no conditions are true, undefined is returned.||
ifs(condition1, value1, condition2, value2, …)
ifs( A<60,"Less than 1 hour",
A<120, "More than 1 hour but less than 2 hours",
A>=120, "More than 2 hours")
|not||Returns values that are not true.||
|and||Returns true if both conditions are met. Else, returns false.||
x and y
if(A=="San Francisco" and
B=="Chrome", "Valid user", "Invalid User")
|or||Returns true if either condition is met. Else, returns false.||
x or y
if(A=="San Francisco" or B=="Chrome", "Valid user", "Invalid User")
|in||Returns true if the first condition is contained in the second condition.||
x in condition
if("Facebook" in A, "Facebook Corporation", A)
|boolean||Casts the argument to a boolean.||
boolean(value)->false, boolean(alternate value)-> true
|number||Casts the argument to a number.||
number(value to cast)
|string||Casts the argument to a string.||
string(value to cast)
|defined||Determines if a value exists. If a property is not defined on a parent event or profile, this will return false, otherwise this will return true.||
defined(variable to check for existence)
|has_prefix||Determines whether a string starts with another string. This comparison is case-insensitive.||
has_prefix(string to check, prefix)
|has_suffix||Determines whether a string ends with another string. This comparison is case-insensitive.||
has_suffix(string to check, suffix)
|min||Determines the minimum value between two numbers.||
|max||Determines the maximum value between two numbers.||
|floor||Returns the largest integer that is smaller than or equal to the input (ie: rounds down to the nearest integer).||
Returns the smallest integer value greater than or equal to the input (ie: rounds up to the nearest integer).
|round||Returns the nearest integer value of the input value.||
|upper||Cast string property values to uppercase.||
upper(A); upper("hello") -> "HELLO"
|lower||Cast string property values to lowercase.||
lower(A); lower("FacEBook") -> "facebook"
If haystack is a string and pattern matches at least one substring, extracts the result from the first pattern match in haystack. The result is a string equal to the entire regex match, or if capture group is specified, only that portion of the match.
regex_extract(haystack, pattern, <optional capture group #>)
Returns true if the pattern matches any part of the string.
regex_match("zzhaystackzz", "ha(..)ack") -> true
Returns the date/time difference between two date/time values. Users have the option of getting the time difference in one of these units:
D: number of days between start_date and end_date.
M: number of months between start_date and end_date.
Y: number of years between start_date and end_date.
MD: number of days between start_date and end_date after subtracting whole months.
YM: number of whole months between start_date and end_date after subtracting whole years.
YD: number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart.
Please also note, that in order to get the current date, users can use TODAY().
datedif(registrationdate,TODAY(), "M") -> 5
Returns the length of the string or the list.
len (string) or len (list)
len("Canada") -> 6
Returns characters from the beginning of a given string.
left("Canada",3) -> "Can"
|right||Returns characters from the end of a given string||
right("Canada",3) -> "ada"
|mid||Returns characters from the middle of a given string||
mid(string, first_index, num_of_characters)
mid("Canada",1,4) -> "Cana"
Use the following numeric operators in the Formula field to modify your custom property using:
- + : Addition. Can also be used to create a concatenation.
- - : Subtraction
- * : Multiplication
- / : Division
- % : Modulo
Use the following comparison operators in the Formula field to modify your custom property:
- < : The first number is strictly less than the second number.
- > : The first number is strictly greater than the second number.
- >= : The first number is greater than or equal to the second number.
- <= : The first number is less than or equal to the second number.
- == : The first argument is equal to the second argument. If both arguments are strings, the comparison is case-insensitive.
- != : The first argument is not equal to the second argument. If both arguments are strings, the comparison is case-insensitive.
- False : Represents the literal value of boolean false.
- True : Represents the literal value of boolean true.
- Undefined : Represents the literal value of cases that aren’t defined.
Use custom properties to create arbitrary ranges of your numerical properties. This is applicable when you want to create age groups from age, income classes from salary, and other numeric property transformations relevant to your business.
If you have a property for “Days since registration” and you want to bucket the users into “Months since registration” (0-1 months: X users, 1-6 months: Y users, 6+ months: Z users), you can use custom properties.
Take the property of “Days since registration” and create a new property called “Months since registration" with this transformation:
Ifs( A/30 <= 1, "0-1 months", A/30 <=6, "1-6 months", A/30 >6, "More than 6 months" )
where each instance of "A" is replaced with the property "Days Since Registration".
Merge or Rename Values to Fix Implementation Issues
Use custom properties to combine multiple property values into one. This is helpful when customers want to take multiple variations of a property value (e.g. facebook, fb, fbsocial) and then combine them into one property value (e.g. facebook).
If you send values into Mixpanel with variations (even though they may have been minor) and you want to correct this issue by grouping those values together.
A marketing manager wants to understand what portion of the user base is coming through a social traffic acquisition path. They want to group all social channel values into a single value, and keep the rest of the channels as-is.
They can create a custom property using the channel with this transformation:
if("Facebook" in A or "Linkedin" in A or "Twitter" in A, "Social", A)
Add Domain Knowledge from Existing Data to Make Data More Accessible
Capture your business logic with Custom Properties to add meaning to your data in Mixpanel, and empower the rest of your team to ask more questions with ease. Take signals in your data and add domain-specific understanding to help other teams unfamiliar with your data model explore your data.
For example, take the case where the marketing team for a music streaming service wants to understand the adoption of original music within their platform. The logic to determine which songs are "original" might be a bit complicated for members outside the product team to discover.
The product team can take these property values and add on domain understanding as a new property, so more team members can dig into the data and drive insights for their needs.
In this example, let’s say that there is an event called “Media Played”, that has the properties "mediaType" (values of 0 or 1, which really mean song (0) or video (1), "Artist" (string, where if the string contains "myflix", then it means that’s an original), so a new custom property could be created to define whether something is an "OriginalSong" (true/false) by combining the logic from "mediaType" and "Artist":
IF(mediaType ==0 AND “myflix” IN Artist, true, false)
Create New Properties Based on Values of Different Properties
Use custom properties to create a new property using the values of multiple other properties.
A marketplace company wants to track total purchase amount for an order, but the per-unit price is passed as a property and the number of items is passed as a property.
They can create a custom property using “price” and “quantity” with this transformation:
Compute the Number of Days Between Two Date Properties
Use custom properties to compute the date/time difference between two date properties. You can also use the special "TODAY()" function to find the difference between a date property and the current date/time. This is ideal when you want to transform a "DateofBirth" property into “age” or a "Created" property into “days active since registration”.
A new custom property can be defined by taking into account the “Created” property and using the following transformation:
DATEDIF(Created, TODAY(), “D”)
This will create the following output:
Modify Defined Properties
Use custom properties to create a new property if and only if a property is defined.
A telco company charges its customers based on talk-time (minutes spoken) and on apps purchased. If the company wants to track the average duration per minute, they would want to restrict the calculation to just the purchases for talk-time (where duration (minutes) is defined).
They can create a custom property using “Duration” and “Amount” with this transformation:
if(defined(A), B/A, B)
Check whether Property Values Are the Same
Use custom properties to create a new property if two property values are the same.
A company wants to find out what percentage of purchases are being made by users that have changed countries since sign up.
They can create a custom property to determine whether the two country values are the same with this transformation:
Transform String Property Values to Upper/Lowercase
Use custom properties to change the case of a string property value.
If a company that sells ice-cream wants to look at popular pie flavors, and if the flavors were written with different casing (“vanilla”, “Vanilla”, vaNilla”), the three values would show up differently as opposed to being the same.
They can create a custom property that combines and casts all these values to the same case using this transformation:
upper(A) or lower(A)
Extract Domain from Email Address
Extract the domain of the email from an email address. You can parse out parts of a string using regular expressions, including parsing out the domain of an email address using the following transformation:
This provides the following output:
Query a List with an Index
Use list referencing with custom properties to parse out any part of a list by an index.
Let’s say you have a list of recommendations as a property, and you’d like to parse out the first recommendation as another string property.
You can parse out the first delivery ID in a list property with several DeliveryIDs:
This creates the following output:
Saving Custom Properties
When you create custom properties and select Save as Custom Property, your created custom property will be private by default. You can also add a description at this stage, so you and your colleagues can know what the custom property is for.
Sharing Custom Properties
You can also decide to save the custom property and share that custom property with specific colleagues, teams or the entire organization by clicking "Save and Share":
Custom Properties in Lexicon
You can view all your saved custom properties in Lexicon. Navigate to Lexicon by clicking on Data Management and select Lexicon. Once in Lexicon, select either the EVENT PROPERTIES or USER PROFILE PROPERTIES tab, then click the dropdown list that says All Types and select Custom Properties from the list. This will filter your properties list to only custom properties.