How do I build segmentation expressions?

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:

  1. Open up your Mixpanel project, click on Segmentation, then chose an Event and Property.
  2. Open up the developer console (on Chrome, Ctrl + Shift + J for Windows/Linux; Cmd + Opt + J for Mac) > Network, and search for “segmentation.”
  3. Scroll down to Query String Parameters in the XHR request to find “on.”
  4. Filter your property by selecting the arrow to the right.
  5. Open the XHR request and scroll down to Query String Parameters to find “where.”

alt text

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, your where parameter would be:

(properties["$browser"] == "Chrome" and not "" in properties["$email"])