I want to create a custom property that filters property values where the value contains the letters "page" at any point in the string. How can I do this?
Hi Lois, 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 filters property values containing the letters "page" at any point in the string, you can use the in
function in Mixpanel's custom property formula. Here's how you can do it: 1. First, create a new custom property by clicking the plus button to the right of the search bar and selecting Event Property or User Property.2. In the formula field, you can use the following expression: LBKSif("page" in lower(A), A, null)LBKS
Let's break down this formula: - lower(A)
: This converts the property value (represented by A) to lowercase, ensuring case-insensitive matching.
- "page" in lower(A)
: This checks if the string "page" is contained anywhere in the lowercase version of the property value.
- if(..., A, null)
: If the condition is true, it returns the original property value (A). If false, it returns null.This custom property will return the original value if it contains "page" (case-insensitive), and null otherwise.You can adjust "A" to be the specific property you want to filter, for example, if you're filtering a property called "screen_name", you would use: LBKSif("page" in lower(screen_name), screen_name, null)LBKS
Remember to give your custom property a meaningful name and description before saving it.For more information on creating custom properties and using functions like in
and lower
, 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! 📚
Yes, you can definitely use a regex match to create a custom property in Mixpanel. The regex_match
function is perfect for this scenario, especially when you need more complex pattern matching than simple string containment.Here's how you can modify the custom property to use regex_match: LBKSif(regex_match(A, ".**page.**"), A, null)LBKS
Let's break down this formula: - regex_match(A, ".**page.**")
: This function checks if the property value (A) matches the regular expression pattern ".page.".
- ".**" means "any character, any number of times"
- "page" is the literal string we're looking for
- So this pattern will match if "page" appears anywhere in the string- if(..., A, null)
: If the regex_match is true, it returns the original property value (A). If false, it returns null.This regex pattern is case-sensitive. If you want to make it case-insensitive, you can use: LBKSif(regex_match(lower(A), ".**page.**"), A, null)LBKS
Remember to replace 'A' with your specific property name.The regex_match
function in Mixpanel uses the PCRE2 regex engine, which allows for powerful pattern matching capabilities. You can adjust the regex pattern to fit your specific needs, such as matching at the beginning of the string ("^page.**"
), end of the string (".*page$"
), or more complex patterns.For more details on using regex in 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.