Creating customer segments

You can group customers who have similar characteristics into a customer segment. You can build your own customer segments by combining filter names, operators, and values in the editor on the Customers page or by clicking Create segment on the Segments page and using the editor on the segment details page. In addition, your Shopify admin includes some default customer segments and templates that you can change to suit your needs, or use as a starting point to create a new customer segment.

Before you begin creating customer segments, learn about the different components of a customer segment, and the filters that are used to build customer segments.

Using the query editor to create customer segments

The ShopifyQL query editor represents the customer segment as a query using ShopifyQL, also known as Shopify Query Language. Every segment has the required FROM and SHOW clauses included by default, and you can't edit those clauses from their default values. To customize your customer segment, update the values in the WHERE clause to include the filters that you want to use. The default query is formatted as follows, with the [filters, operators, values] representing where you add your custom segment content:

FROM customers
SHOW customer_name, note, subscription_status, location, orders, amount_spent
WHERE [filters, operators, values]
ORDER BY updated_at

The editor helps you to build your customer segments without requiring a deep knowledge of query languages. As you add components to your customer segment, you're provided with a list of the available filter names, operators, and values that you can use.

Changes you make to the segment's filters are reflected in the query editor's WHERE clause in real-time. When you make a change to the pre-written query, select ▹ Run in the query editor to update the customer segment with your changes.

To hide the query editor content, click the up chevron . When the query editor is hidden, click the down chevron to display it.

You can get assistance building your customer segment query by clicking any of the following icons:

Overview of customer segment icons for accessing more help.
IconIcon nameFunction
The customer segment Filters iconFiltersOpens lists of available filter names. The lists are categorized into Shopify-based filter names and filter names based on any Metafields that you might have that use the supported content types. When you click a filter name, the code is entered into the editor.
The customer segment Templates iconTemplatesOpens a list of default customer segments as a basis for building your own customer segment.
The customer segment Redo iconRedoApplies the most recent undone change back to the query.
The customer segment Undo iconUndoUndoes the most recent action.
The customer segment Sort iconSort byOpens a list of options for how you want the customers in your segment to be sorted, such as Last order date and Newest to oldest. This also updates the ORDER BY condition for the query.

You can use the following keyboard shortcuts to navigate the ShopifyQL query editor faster:

List of supported keyboard shortcuts for the ShopifyQL editor on both Windows and macOS devices.
ActionShortcut on WindowsShortcut on macOS
Undo Ctrl + Z Command ⌘ + Z
Redo Ctrl + Y Command ⌘ + Shift ⇧ + Z
See all shortcuts Ctrl + / Command ⌘ + /
Filter library Ctrl + Alt + \ Control ⌃ + Shift ⇧ + F
Template library Ctrl + \ Control ⌃ + Shift ⇧ + T
Select filterEnter ⏎Return ⏎
Select query Ctrl + A Command ⌘ + A
Apply filters Ctrl + Enter ⏎ Command ⌘ + Return ⏎
Clear editor Ctrl + Delete ⌫ Command ⌘ + Delete ⌫

Create a new customer segment

You can build a new customer segment by combining filter names, operators, and values. After you create a new customer segment, it displays in the Segments list.

You can create a new customer segment using any of the following options:

Create a customer segment using a template

Your Shopify admin includes templates for you to use as a starting point to help you to build your own customer segment. You can add one or more templates to your customer segment.

Steps:

  1. From your Shopify admin, go to Customers.

  2. Click the Templates icon.

  3. In the Templates search, click the type of template that you want to use.

  4. Click Use this template next to the template that you want to use. The corresponding filter names, operators, and values populate in the editor.

  5. Optional: Select a connector, and then add another template to the editor.

  6. In the query editor, make the appropriate changes.

  7. To test your segment, click Run query or ▹ Run. The customers who match the criteria are listed below the editor. The number of customers who match the criteria is displayed above the editor.

  8. Review the AI-generated segment description to ensure that the description matches the segment that you want to create, and then make any necessary changes.

  9. Click Save segment, and then enter a name for the segment.

  10. Click Save.

Create a customer segment using an existing customer segment

Your Shopify admin includes default segments that display Shopify as the author. You can use these segments or any other segments that you already created as a starting point to help you build a new customer segment.

Steps:

  1. From your Shopify admin, go to Customers.

  2. Click Segments.

  3. From the segments list, click an existing customer segment.

  4. In the query editor, make the appropriate changes.

  5. To test your segment, click Run query or ▹ Run. The customers who match the criteria are listed below the editor. The number of customers who match the criteria is displayed above the editor.

  6. Review the AI-generated segment description to ensure that the description matches the segment that you want to create, and then make any necessary changes.

  7. Click Save segment.

  8. To create a new customer segment, click Save as new segment, and then enter a new name.

  9. Click Save.

Create or modify a customer segment by manually editing the ShopifyQL query

You can customize your customer segment by editing the ShopifyQL query directly in the segment query editor.

The query editor is designed to help you to build your customer segments. As you add components to your customer segment, you're provided with a list of the available filter names, operators, and values that you can use.

If a query isn't valid, then an error message displays at the bottom of the query editor to indicate which line the error is on. Errors in the query are underlined in red, and you can hover your cursor over the error to get tips on how to resolve the issue.

Learn more about using ShopifyQL and building queries.

Steps:

  1. From your Shopify admin, go to Customers.

  2. Click Segments.

  3. From the segments list, click an existing customer segment or click Create segment to create a new segment.

  4. Click in the query editor to display the default query.

  5. Customize the default query in any of the following ways:

    • In the WHERE dialog, select from the list of available query options:
      1. Choose a filter, such as customer_cities.
      2. Choose an operator, such as CONTAINS
      3. Choose a value, such as CA-ON-Toronto.
    • Manually type in the filters, operators, and values that you want to apply to your segment.
  6. Optional: To add more conditions to your filter, include OR or AND as a connector, and then continue building the filter.

  7. To complete your segment, click Run query or ▹ Run. The customers who match the criteria are listed below the editor. The number of customers who match the criteria is displayed above the editor.

  8. Review the AI-generated segment description to ensure that the description matches the segment that you want to create, and then make any necessary changes.

  9. Click Save.

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