
If you send the same email to every customer on your list, Shopify customer segments are the fix. This guide is for store owners and marketers who want to pick audiences properly, and for the developers who back them up. You will see which filters exist, how to write a segment by hand, and ten queries you can paste in today.
What are Shopify customer segments?
A segment is a group of customers defined by rules. Shopify re-evaluates the rules as customer data changes, so people join and leave the group without you touching it. Every segment is a ShopifyQL query. In the segment editor the FROM and SHOW parts are fixed, and you only edit the WHERE conditions, as the segment help page explains.
Search results for this topic tend to stop at “click Customers, then Segments, add a filter”. That works for a first segment. It does not tell you what the filters are called, how dates behave, or why a query returns zero people. Those are the parts below.
How do I create a customer segment in Shopify?
You have four routes, and they all end up as the same query text:
- Build it with filter buttons in the Customers area.
- Start from one of Shopify’s templates.
- Copy an existing segment and edit it.
- Write or edit the query directly. Errors are underlined in red with a message.
Sidekick, Shopify’s assistant, can also draft a query from a plain sentence such as “customers who last ordered more than 90 days ago and are subscribed to marketing emails”. Read the result before saving. The help page says the same.
One catch: if you type into the query, nothing changes until you press Run.
Segment query language: the rules that bite
The segment query language reference is short and worth reading once. The points that cause most failures:
- Text and enum values are case-sensitive.
'SUBSCRIBED'matches,'subscribed'does not. - Tag matching with
CONTAINSis not case-sensitive. - Decimals use a full stop and there are no thousands separators:
amount_spent > 999.99. - A query can hold 10 clauses at most.
- Relative dates use
-30d,-2w,-6mand-1y, counted in your shop’s time zone. ANDbinds beforeOR. Use brackets when you mix them.- Maths and string functions such as
SUMorLOWERare not supported.
The main attributes are number_of_orders, amount_spent, first_order_date, last_order_date, abandoned_checkout_date, customer_countries, customer_tags, email_subscription_status, sms_subscription_status, rfm_group and predicted_spend_tier. There are also functions: products_purchased, orders_placed, anniversary() and a handful of storefront and email-activity ones.
Ten segments to copy
Paste each WHERE condition into the editor and look at the match count before you save. Thresholds are examples; set them from your own order data. Country values are two-letter codes.
- VIP customers:
number_of_orders >= 3 AND amount_spent > 500 - Lapsed buyers, no order in about six months:
number_of_orders >= 1 AND last_order_date < -180d - New customers from the last 30 days:
number_of_orders = 1 AND first_order_date > -30d - High spenders in one country:
amount_spent > 300 AND customer_countries CONTAINS 'CA' - Subscribers who never bought:
email_subscription_status = 'SUBSCRIBED' AND number_of_orders = 0 - Recent abandoned checkouts:
abandoned_checkout_date > -7d - Bought from a product group in the last year:
products_purchased MATCHES (tag = 'Sports wear', date >= -12m) - Subscribed but never bought that group:
email_subscription_status = 'SUBSCRIBED' AND products_purchased NOT MATCHES (tag = 'Sports wear') - Wholesale accounts by tag:
customer_tags CONTAINS 'wholesale' - Birthday today, if you store a date in a customer metafield:
anniversary('metafields.facts.birth_date') = today
What about “viewed a product but did not buy”? Shopify has storefront_event.product_viewed and collection_viewed, but the reference does not document their parameters. Build that one with the filter buttons and read what the editor generates. It also depends on visitors having accepted tracking, so the group will be smaller than you expect.
Not sure where to set a VIP line? The rfm_group filter (recency, frequency, monetary value) does the sorting for you, at the cost of control. Pick its values from the dropdown.
From goal to filters to action
| Goal | Filters | What you do with it |
|---|---|---|
| Thank your best customers | number_of_orders, amount_spent | Early access or a handwritten-style thank-you |
| Win back lapsed buyers | last_order_date, number_of_orders | Win-back email, no discount on the first message |
| Look after new buyers | first_order_date, number_of_orders | Care advice and a review request |
| Market to one country | customer_countries, amount_spent | Local shipping or event news |
| Get subscribers to order | email_subscription_status, number_of_orders | First-order message |
| Follow up checkouts | abandoned_checkout_date | See abandoned cart recovery |
| Cross-sell | products_purchased | Refill or accessory email |
| Trade customers | customer_tags | Price list, restock news |
Segments versus tags versus collections
A segment is a question you ask of your data, and the answer changes. A tag is a label that stays put until someone or something removes it. Use a tag when the fact is not in Shopify already, such as “approved wholesale” or “met at a trade show”, and a segment when Shopify can work it out. Tags can feed segments, as example 9 shows. Our piece on customer tags and lifecycle automation covers the split in detail.
Collections group products, not people. The only link is that a segment can filter on which products someone bought.
Using segments in email, SMS, Flow and the API
Pick a segment as the audience when you create a Shopify Email campaign. Marketing apps vary in whether and how often they sync segments, so check each app’s documentation before you rely on it.
In Shopify Flow there is a “customer joined segment” trigger, which can add a tag or alert your team. It acts on customers who join after the workflow is live, so existing members are not back-filled.
For developers, the Admin GraphQL segments query returns segments with their names and defining queries, and supports first, after, a search query and sorting. Check the docs for the current API version and the access scopes your app needs. If you are starting a custom app, the build guide covers the basics.
Consent comes before segments
A segment is just a list of people. Whether you can contact them is a separate question. Put a marketing-state condition in every audience you intend to email or text, for example email_subscription_status = 'SUBSCRIBED'. GDPR, ePrivacy, CCPA and SMS rules differ by country, so check local law, and honour unsubscribes. Browsing-based segments rely on tracking consent as well. Keep sensitive personal details out of tags and metafields you use for targeting.
Mistakes I would check for first
- No consent condition, so unsubscribed people get mail.
- Wrong case in an enum value, giving zero matches with no obvious error.
- A VIP threshold that matches five people, or half the store.
- Overlapping segments that nobody can tell apart. Name them by purpose, like “Lapsed 180d, subscribed”.
- Treating a segment as a record. It moves; export or tag if you need a snapshot.
- Skipping the match count before a send.
Frequently Asked Questions
Do I need to know ShopifyQL to make a segment?
No. The filter buttons, templates and Sidekick all work without it. The query text helps when you want exact control or want to copy a segment to another store.
Can one customer be in several segments?
Yes. Segments are independent, so one person can match many of them at once.
How are segments different from tags?
Segments are calculated from data and update themselves. Tags are labels added by people, apps or workflows and stay until removed.
Can I email a segment that includes unsubscribed customers?
You should not. Add a subscription-status condition and check the rules in your region.
How many segments can I have?
The query reference lists 250 as the number of segments you can query through the API. Check that page for the current figure before planning a large set.
Conclusion
Start with three Shopify customer segments: new buyers, lapsed buyers and subscribers who never ordered, each with a consent condition. Check the match counts, name them clearly and review them every quarter. If you would like help with this, CYPHEX can plan and deliver it for you, with one project lead as your contact. Our Shopify services page lists what we cover.
Stock photography provided by Pexels under the Pexels License.
