Segment customers who bought a product in Shopify
A new colour of the Summit Hoodie is coming, and the first people to hear about it should be the ones who already bought one. Shopify's segment editor filters on products purchased, using the product's ID. This tutorial builds a segment of everyone who bought the Summit Hoodie.
Written · Shopify admin, desktop steps · 4 minutes read
The worked example
| Customers in the store | 214 |
| Bought the Summit Hoodie | 37 |
| Share of the store | 17.29% |
| Hoodies bought | 41 |
| Hoodie revenue | $1,845.00 |
Download the buyers worksheet: bought-product-segment.csv (175 bytes, md5 fc04fdd2ae9b120c1a79faef0b5ab8cf).
A worksheet of six sample buyers from the segment: hoodies bought and amount spent on hoodies. The six bought 9 hoodies for $405.00 between them.
1Find the product ID
From your Shopify admin, go to Products and open the Summit Hoodie. The product ID is the number in the admin address for that product page. Note it down; the segment filter needs the ID, not the product name.
2Open the segment editor
From your Shopify admin, go to Customers, click Segments, then click Create segment. The query editor opens with the default query in place.
3Add the products-purchased filter
Click into the WHERE area and build the filter products_purchased MATCHES (id = 1234325), replacing the number with your product's ID. The editor offers the filter name and the MATCHES operator as you type. The value must be the numeric ID; a name typed in does not match.
4Run the query and read the count
Click Run query. The matching customers list below the editor and the count shows above it. The worked example shows 37 customers. If the count is zero and you know the product sold, the ID is the first thing to check again.
5Save the segment
Review the AI-generated description, then click Save segment, name it Bought the Summit Hoodie, and click Save.
The arithmetic
The Summit Hoodie costs $45.00.
| Count | Figure | Check |
|---|---|---|
| Customers who bought it | 37 | 37 of 214 |
| Share of the store | 17.29% | 37 / 214 |
| Hoodies bought | 41 | 41 units |
| Hoodie revenue | $1,845.00 | 41 × $45.00 |
37 divided by 214 is 17.29%. 41 hoodies at $45.00 each is $1,845.00. The 37 customers bought 41 hoodies between them, so a few bought more than one.
Held at the counter
The filter needs the numeric ID, not the name. The filter products_purchased MATCHES (id = 1234325) works; the product name in place of the number does not. Copy the ID from the product's admin page rather than typing it from memory.
One customer counts once. A customer who bought the hoodie twice still appears once in the segment count. The 37 in this example is customers, not orders, and the 41 is hoodies.
Any variant counts. Buying any variant of the product counts as buying the product. A segment for the hoodie catches the navy and the forest green alike, with no extra filter needed.
Sources
- Creating customer segments — Shopify's help pages: the query editor, the Run query preview, and the save steps.
- Components of a customer segment — Shopify's help pages: the products_purchased MATCHES example with a product ID.