The easiest way to build Segmentation expressions is by looking at the requests within the standard Mixpanel Segmentation report. Find the on/where parameters for segmentation API requests:
- Open up your Mixpanel project, click on Segmentation, then chose an Event and Property.
- Open up the developer console (on Chrome, Ctrl + Shift + J for Windows/Linux; Cmd + Opt + J for Mac) > Network, and search for “segmentation.”
- Scroll down to Query String Parameters in the XHR request to find “on.”
- Filter your property by selecting the arrow to the right.
- Open the XHR request and scroll down to Query String Parameters to find “where.”
You can apply expressions to these where and on parameters to perform mathematical operations, logical operations, or typecasts. See additional technical documentation on writing segmentation expressions.
Examples of selectors for segmentation expressions
Equals | (properties["$city"] == "Chicago")
Does not equal | (properties["$city"] != "Chicago")
Contains | ("Facebook" in properties["$referring_domain"])
Does not contain | (not "Facebook" in properties["$referring_domain"])
Set | (defined (properties["$device"]))
Not set | (not defined (properties["$device"]))
So if you wanted to create a segmentation expression where browser is Chrome and email does not contain @yourdomain.com, your where parameter would be:
(properties["$browser"] == "Chrome" and not "@yourdomain.com" in properties["$email"])