Components of a customer segment

Customer segments are composed of one or more filters. A filter is built using a filter name, an operator, and a value as its components.

The components of a customer segment with one filter

The components of a customer segment filter.
ComponentComponent name
1filter name
2operator
3value

You can use more than one filter in a customer segment. In this case, you use connectors between each filter. A customer segment that uses multiple filters is built in the following way:

A customer segment with 2 filters joined by the AND connector

Learn more about the specific filters that are used to build customer segments.

Filter names

A filter name is a criterion that is used to select customers for a customer segment. For example, if you want to select all your customers who subscribe to your marketing emails, then you use the email_subscription_status filter name.

Functions

You can use functions to add optional parameters to a filter. The additional parameters are added in parentheses after the filter name.

For example, you can add a parameter using a marketing activity ID to help filter all your customers who have opened a certain email: shopify_email.opened(activity_id: 123) = true

The following are supported function attributes:

Operators

An operator is used to define the relationship between the filter name and the value. For example, if you want to create a segment of customers who have placed 5 or more orders, then you use the operator >= to indicate greater than or equal to. In this case, you would add the value 5, that is, >=5.

The following are examples of other operators:

  • Between: BETWEEN <value1> AND <value2>
  • Is equal to: =
  • Is not equal to: !=
  • Greater than: >
  • Smaller than: <
  • Smaller or equal to: <=
  • Contains this exact value: CONTAINS
  • Doesn't contain this exact value: NOT CONTAINS

The operators that are available for a filter name depend on which filter name you use. Learn more about which operators are available for each filter name.

Using the IS NULL and IS NOT NULL operator and value paired suggestions

The IS NULL operator and value paired suggestion is used to filter customers for whom value data doesn't exist for the given filter. The IS NOT NULL operator and value paired suggestion is used to filter customers for whom any value data does exist for the given filter. IS NOT NULL means that a value has data that exists, and includes all customers who have any value and not a specific value.

Examples of how to use the IS NULL and IS NOT NULL operator and value paired suggestions in a customer segment
IS NULLTo create a customer segment of customers who have never abandoned a cart at checkout, use the IS NULL operator and value paired suggestion. The customer segment is customers whose profiles don't have any value entered in the abandoned checkout date field.

In the editor, the customer segment is the following:

abandoned_checkout_date IS NULL
IS NOT NULLTo create a customer segment of all customers who have abandoned a cart at checkout before, use the IS NOT NULL operator and value paired suggestion. The customer segment is all customers whose profiles have a value entered in the abandoned checkout date field.

In the editor, the customer segment is the following:

abandoned_checkout_date IS NOT NULL

Values

A value is the characteristic of a customer that is used to include or exclude the customer from a customer segment. The value is used in combination with the filter name and operator. For example, if you want to select your customers who subscribe to your marketing emails, then you use the value 'SUBSCRIBED'. Customers who don't subscribe to your marketing emails are excluded from the customer segment.

Connectors

If you use multiple filters, then you combine them by using the AND and OR connectors. Connectors help you to make the focus of your customer segment as broad or as narrow as you need it to be.

  • The AND connector narrows the focus of your customer segment because a customer must meet all the criteria to be included.
  • The OR connector broadens the focus of your customer segment because a customer can meet any of the criteria to be included, but doesn't need to meet all the criteria.

Using the AND connector

To create a customer segment that includes only your email subscribers who have placed 5 or more orders, use the AND connector to combine both filters.

Conceptually, this customer segment is as follows:

Customers who subscribe to your marketing emails and customers who have placed 5 or more orders.

In the editor, the customer segment displays as follows:

email_subscription_status = 'SUBSCRIBED' AND number_of_orders &gt;= 5

Your customer segment only includes your email subscribers who have placed 5 or more orders. The customer segment doesn't include the following customers:

  • Customers who don't subscribe to your marketing emails.
  • Customers who do subscribe to your marketing emails, but who have placed fewer than 5 orders.

Using the OR connector

To create a customer segment that includes your email subscribers or customers who have placed 5 or more orders, use the OR connector to combine both filters.

Conceptually, that customer segment is as follows:

Customers who subscribe to your marketing emails or customers who have placed 5 or more orders.

In the editor, the customer segment displays as follows:

email_subscription_status = 'SUBSCRIBED' OR number_of_orders &gt;= 5

Your customer segment includes the following groups:

  • All your email subscribers, whether or not they've placed 5 or more orders.
  • All your customers who have placed 5 or more orders, whether or not they subscribe to your emails.

Using both the AND and OR connectors

You can combine several filters using both AND and OR connectors. The best practice is to group your filters using brackets.

If you don't use brackets, then the filters that are combined using AND are applied before the filters that are combined using OR.

Customer segments with brackets

If you want to limit your customer segment to your email subscribers who have either spent more than $100 USD or who have placed 5 or more orders, then use brackets to build the following customer segment:

   (amount_spent &gt; 100 OR number_of_orders &gt;= 5) AND email_subscription_status = 'SUBSCRIBED'

In this case, the OR connector is applied before the AND connector. As a result, your customer segment includes both of the following:

  • your email subscribers who have spent more than $100 USD
  • your email subscribers who have placed 5 or more orders

Customer segments without brackets

The following customer segment doesn't use brackets:

amount_spent > 100 OR number_of_orders >= 5 AND email_subscription_status = 'SUBSCRIBED'

In this case, the AND connector is applied before the OR connector. This means the filter is interpreted as if you had included these brackets:

amount_spent > 100 OR (number_of_orders >= 5 AND email_subscription_status = 'SUBSCRIBED')

As a result, your customer segment includes all the following:

  • your customers who have spent more than $100 USD, whether or not they subscribe to your emails
  • your email subscribers who have placed 5 or more orders

Test your understanding of customer segment filter components

Use the following example to build your own customer segment on the Customers page of your Shopify admin:

(amount_spent &gt; 100 OR number_of_orders &gt;= 5) AND email_subscription_status = 'SUBSCRIBED'

Learn more about creating customer segments.

Can’t find the answers you’re looking for? We’re here to help.