Analytics / ShopifyQL · Improvement

ShopifyQL's MATCHES
Filter reports not just by "who the customer is" but by "what they did"

In the ShopifyQL editor in Analytics, MATCHES has been added. In the WHERE clause, you can now filter reports by a customer'sbehavioras a condition. Since you can use the same MATCHES syntax as Customer Segmentation, your segment and report definitions stay consistent.

What's on this page
  1. What actually changes (understand it in 30 seconds)
  2. Syntax diagram: how to write MATCHES
  3. Why "definitions stay consistent"
  4. The difference between a regular WHERE and MATCHES
  5. Requirements and limitations
  6. 5 key points for developers
  7. 3 use cases you can apply at work
  8. A one-line summary you can use in a pitch

1What actually changes

Until now, in ShopifyQL within Analytics, you could only filter customers by "who they are" (attributes) .
Now, MATCHES has been added, and"what they did" (behavior) can now be used as a WHERE clause condition to build reports.

Before: only "who they are"

You could only filter by attributes tied to the customer—country, signup date, tags, and so on.attributes. Behavioral conditions like "people who bought a lot recently" couldn't be written directly in a report.

Now: "what they did" too

Behaviors like purchase count, quantity, and time periodbehaviorcan be turned into WHERE clause conditions. For example, you can directly filter for "customers who purchased 2+ items in the last 30 days."

2Syntax diagram: how to write MATCHES

A real example from the article: "customers who purchased 2 or more items in the last 30 days" — the query to extract them:

FROM customers
SHOW customer_id, email
WHERE products_purchased MATCHES (quantity >= 2, date >= -30d)
GROUP BY customer_id

What each line does

ClauseRole
FROM customersTargets customer data.
SHOW customer_id, emailSpecifies the columns to show in the results.
WHERE ... MATCHES (...)This is the key part here.products_purchasedAgainst the action (having purchased a product), narrows down to only the customers that match the conditions inside the parentheses.
quantity >= 2A quantity of 2 or more.
date >= -30dFrom the time of execution,relative, within the past 30 days. Represents 'the last 30 days' rather than a fixed date.
GROUP BY customer_idAggregates by customer.
The key point is the MATCHES (condition, condition) form. The multiple conditions inside the parentheses (quantity and period)the same purchase actionare evaluated together against it. So '2 or more' and 'within 30 days' are not separate people; instead,customers for whom they hold true as a single purchase actionare returned.

3Why 'the definition stays consistent'

The crux of the article is the point that 'the MATCHES logic used in Customer Segmentation works as-is in Analytics too.'Because the same syntax means the same thing, the numbers in segments and reports don't drift apart.

MATCHES Shared syntax and logic Customer Segmentation Build segments by behavior (extracting targets for promotions and delivery) Analytics(ShopifyQL) Filter reports by behavior (aggregating counts and sales) Same conditions → same set of customers → segments and reports match
When you change a segment's definition, the report side can follow along by writing the same conditions.Being able to manage 'delivery targets' and 'aggregation targets' in a single languageis what pays off.

4The difference between a regular WHERE and MATCHES

ItemRegular WHERE (attribute filter)WHERE ... MATCHES (behavior filter)
What it narrows down Who someone is Customer attributes such as country, signup date, and tags What they did Behavior such as purchase quantity and time period
Syntax column operator value (e.g., country = 'JP') behavior field MATCHES (condition, condition)
Multiple conditions Joined with AND / OR List them inside parentheses to evaluate them together against the same behavior
Time period You can use relative dates like date >= -30d
Consistency with Segmentation Yes The same syntax is shared with segments

* Attribute filters and behavior filters can be used together (for example, combining "customers in Japan" with "purchased 2 or more items in the last 30 days").

5Requirements and limitations

The ShopifyQL editor in Analytics

It's used in the ShopifyQL editor within Analytics. You write MATCHES in the WHERE clause.

Details on syntax, examples, and limitations

such as the list of supported fields and upper limits,the detailed limitations are not covered in this article. They are consolidated in the Shopify Help Center, so check there before implementing.

Plan and regional requirements, and the types of behavior fields available with MATCHES, are not explicitly stated in the article (not stated). Since the article says "refer to the Help Center for syntax, examples, and limitations," treat it on the assumption that you'll verify against the latest Help Center spec before production use.

6Five points engineers should know

WHERE

1. Use it in the WHERE clause

MATCHES is a behavior filter written in the WHERE clause. Use it in combination with existing ShopifyQL syntax such as SHOW / GROUP BY.

2. Capture both attributes and behavior

You can use the traditional "who they are (attributes)" filters together with the "what they did (behavior)" MATCHES in the same query. You can slice customers along both axes.

3. Relative dates (-30d)

You can specify relative dates based on the time of execution, like date >= -30d. There's no need to update fixed dates, so you can templatize reports as "the last N days."

4. Same syntax as Segmentation

You can bring Customer Segmentation's MATCHES directly into Analytics. The learning curve is shared, making it easy to validate and port segment definitions.

5. Detailed specs depend on the Help Center

Limitations such as the list of supported behavior fields, whether nesting is allowed, and upper limits are not covered in the article. Before building production queries,check the Help Center's syntax, examples, and limitations, and measure in the editor whether the expected number of results is returned before putting it into production.

7Three use cases you can apply to your work

USE CASE 1

Extract behavior-based lists of high-value customers directly within Analytics

Challenge
You wanted to surface "repeat customers who bought multiple times in the last 30 days," but attribute filters couldn't express behavioral conditions, so you ended up exporting a CSV and tallying it in Excel.
Solution
Write the behavioral condition directly with WHERE products_purchased MATCHES (quantity >= 2, date >= -30d) and pull out customer_id / email.
Impact
Build a high-value customer list as a report right on the spot. Pulling the audience for retargeting or loyalty programs is done in one step.
Technical note
Copy the same condition over to Customer Segmentation as well, and you can run both extraction and delivery on a single shared definition.
Segment Report
USE CASE 2

Stamp out "definition drift" between segments and reports

Problem
Delivery segments (Customer Segmentation) and performance reports (Analytics) wrote their conditions in different ways, so the audience counts and revenue figures didn't match.
Solution
Paste the MATCHES condition you use in a segment straight into the WHERE clause of a ShopifyQL report to tally counts and revenue.
Impact
The "people you sent to" and the "people you counted" now share one definition, so your KPIs stay consistent—and it cuts the cost of explaining things in reviews, too.
Technical note
Keep the condition in one master location and roll it out to both. Make it an operating rule that when you update the segment definition, you also sync the report's WHERE clause.
-30d
USE CASE 3

A template report where you only change the "period × count" thresholds

Problem
Rebuilding a separate report for each loyalty tier—"1+ item in the last 7 days," "5+ items in the last 90 days," and so on—is a hassle.
Solution
Templatize a query where you swap only N and X in MATCHES (quantity >= N, date >= -Xd). Because the dates are relative, there's no need to hand-edit them.
Impact
Mass-produce reports broken out by customer tier, from new to heavy users, with minimal effort. It lays the groundwork for automating your recurring reports.
Technical note
Check the available behavioral fields and condition limits in the Help Center, and before templatizing, verify that each threshold returns the counts you expect.

8A one-line summary you can use in a pitch

"ShopifyQL now has MATCHES added, so you can now target customers bynot just "who they are" but "what they did" (their behavior)and pull them into reports —
and what's more, it uses the same syntax as Customer Segmentation,so your segment and report definitions never drift apart."