Skip to content

Shopify tutorials for the person running the store. Orders, discounts, fulfilment, returns.

Segment customers by purchase history in Shopify

Repeat buyers are the customers worth a different message than first-time browsers: a thank-you, an early look at a new line, a loyalty offer. Shopify's segment editor filters on order history, so a repeat-buyer group is one filter and one save. This tutorial builds a segment of customers with 3 or more orders.

Written · Shopify admin, desktop steps · 4 minutes read

The worked example

Example customers6
With 3 or more orders3
Combined spend of the 3$458.50
Total spend of all 6$547.75

Download the segment worksheet: purchase-history-segment.csv (204 bytes, md5 e4473aafc23a2959240a1c1e9ff7ce28).

A worksheet for the six example customers: order count, total spent, and whether each one lands in the 3-or-more-orders segment. The three in the segment spent $458.50 between them.

1Open the segment editor

From your Shopify admin, go to Customers, click Segments, then click Create segment. The query editor opens with the default query: locked FROM customers and SHOW lines, and a WHERE line for your filters.

2Add the order-count filter

Click into the WHERE area, pick the filter number_of_orders, pick the operator >=, and enter the value 3. The editor suggests the filter name, the operator, and the value as you type. The full line reads WHERE number_of_orders >= 3.

3Run the query and read the count

Click Run query. The matching customers list below the editor and the count shows above it. In the worked example, 3 of the 6 customers have 3 or more orders. If the count is far from what you expected, check the operator: >= 3 includes customers with exactly 3 orders, while > 3 does not.

4Narrow it further if you want

Optional: add AND email_subscription_status = 'SUBSCRIBED' to keep only the repeat buyers you can email. The AND connector narrows the group; OR would widen it.

5Save the segment

Review the AI-generated description, then click Save segment, name it Repeat buyers (3+ orders), and click Save.

The arithmetic

Six example customers, with their order counts and total spent.

CustomerOrdersTotal spent
Maya Chen5$203.25
Jordan Lee4$156.75
Priya Patel3$98.50
Sam Okafor2$61.25
Alex Tremblay1$28.00
Cate Nguyen0$0.00
In the segment (3+ orders)3 customers$458.50

$203.25 plus $156.75 plus $98.50 equals $458.50, the combined spend of the three customers in the segment. All six together spent $547.75.

Held at the counter

Order history counts this store only. A customer who bought from you on another platform, or at a market stall before you recorded it, starts at zero orders in Shopify. The segment sees Shopify orders, not your memory of the customer.

Greater than is not greater than or equal to. A filter of number_of_orders > 3 leaves out the customers with exactly 3 orders. Read the operator before you save.

A segment is live. A customer who places a third order joins the segment on their own, and a refund that drops their count can take them out. The list you save today is not the list next month.

Sources