Custom Properties

This feature is available in the InsightsFunnels, FlowsRetention, Explore and Cohorts reports, as well as Dashboards.

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

Screen_Shot_2020-03-10_at_12.58.02_PM.png

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.

mceclip0.png

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.

mceclip1.png

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.

Functions

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)

Example:

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, …)

Example:

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. 

not(condition)

Example:

not (A)

 and Returns true if both conditions are met. Else, returns false.

x and y

Example:

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

Example:

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

Example:

if("Facebook" in A, "Facebook Corporation", A)

 boolean  Casts the argument to a boolean.

boolean(value)->false, boolean(alternate value)-> true

Example:

boolean(A)

 number  Casts the argument to a number. 

number(value to cast)

Example:

number(A, B)

 string  Casts the argument to a string.

string(value to cast)

Example:

string(A)

 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)

Example:

defined(A)

 has_prefix  Determines whether a string starts with another string. This comparison is case-insensitive.

has_prefix(string to check, prefix)

Example:

has_prefix(A, "United")

 has_suffix Determines whether a string ends with another string. This comparison is case-insensitive.

has_suffix(string to check, suffix)

Example:

has_suffix(A,"States")

 min Determines the minimum value between two numbers.

min(number, number)

Example:

min(A,B)

 max Determines the maximum value between two numbers.

max(number, number)

Example:

max(A,B)

 floor Returns the largest integer that is smaller than or equal to the input (ie: rounds down to the nearest integer).

floor(number)

Example:

floor(A)

 ceil

Returns the smallest integer value greater than or equal to the input (ie: rounds up to the nearest integer).

ceil(number)

Example:

ceil(A)

 round Returns the nearest integer value of the input value.

round(number)

Example:

round(A)

 upper Cast string property values to uppercase.

upper(string property)

Example:

upper(A); upper("hello") -> "HELLO"

 lower Cast string property values to lowercase.

lower(string property)

Example:

lower(A); lower("FacEBook") -> "facebook"

 regex_extract

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  #>)

Example:

regex_extract("iPhone5.1","iPhone(...)",1) ->5.1

 regex_match

Returns true if the pattern matches any part of the string.

regex_match(haystack, pattern)

Example:

regex_match("zzhaystackzz", "ha(..)ack") -> true  

datedif

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(start_date,end_date,unit)

Example:

datedif(registrationdate,TODAY(), "M") -> 5

 

len

Returns the length of the string or the list.

len (string) or len (list)

Example:

len("Canada") -> 6

left

Returns characters from the beginning of a given string.

left(string, num_of_characters)

Example:

left("Canada",3) -> "Can"

right Returns characters from the end of a given string

right(string, num_of_characters)

Example:

right("Canada",3) -> "ada"

mid Returns characters from the middle of a given string

mid(string, first_index, num_of_characters)

Example:

mid("Canada",1,4) -> "Cana"

 

Numeric Operators

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

Comparison Operators

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 Cases

Custom Bucketing

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.

For example:

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".

mceclip0.png

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. 

For example:

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)

mceclip1.png

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.

For example:

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:

A*B

mceclip2.png

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”)

Untitled.png

This will create the following output:

Untitled2.png

Modify Defined Properties

Use custom properties to create a new property if and only if a property is defined.

For example:

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)

mceclip3.png

Check whether Property Values Are the Same

Use custom properties to create a new property if two property values are the same.

For example:

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:

if(A==B,FALSE, TRUE)

mceclip4.png

Transform String Property Values to Upper/Lowercase

Use custom properties to change the case of a string property value.

For example:

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)

mceclip5.png

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:

REGEX_EXTRACT(Email,"@([^.]*)",1)

Untitled3.png

This provides the following output:

Untitled4.png

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:

Deliveries [0]

Untitled5.png

This creates the following output:

Untitled6.png

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. 

mceclip1.png

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":

Screen_Shot_2020-07-09_at_10.12.53_AM.png

 

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.

Untitled7.png

Did this answer your question?

Comments

0 comments

Article is closed for comments.