The Customer Query selector is a powerful tool that helps you target specific customers for your campaigns. This guide will show you how to create queries to find exactly the right customers at the right time.
What is a Customer Query?
A Customer Query is a search filter that automatically finds customers based on specific criteria when your campaign runs. It combines two powerful features:
Shopify's search syntax - The same search language used throughout Shopify
Liquid templating - Dynamic values that change based on when the campaign runs (like dates)
How to Use the Customer Query Field
1. Testing Your Query
Before saving your campaign, always use the Test Query button. This shows you:
How many customers currently match your query
If there are any errors in your query syntax
Important: The test runs with today's date and time, so results may differ when your campaign actually executes.
2. Query Structure
A basic query looks like this:
A dynamic query with Liquid looks like this:
Common Use Cases & Examples
Birthday Campaigns
Find customers with birthdays today:
tag:* searches for tags containing the pattern
{{ "now" | date: "%m-%d" }} generates today's date in month-day format (e.g., "06-15")
Requires customers to have tags like birthday-06-15 for June 15th birthdays
Find customers with birthdays this month:
Uses only the month (e.g., "06" for June)
Works with tags like birthday-month-06
Anniversary Campaigns
Find customers who joined exactly 1 year ago:
Calculates last year's date dynamically
Works with tags like joined-2024-06-15
Tag-Based Targeting
Find VIP customers:
Find customers with multiple tags:
Find customers with any of several tags:
Location-Based Targeting
Find customers in specific city:
Find customers in specific country:
Combine location with tags:
Email Subscription Status
Find customers who accept marketing:
Find customers who don't accept marketing:
Understanding Liquid Templating
Liquid is the templating language that makes your queries dynamic. It's enclosed in double curly braces: {{ }}
Date Formatting
The most common use is formatting dates:
Format
Output
Example
%Y
Year (4 digits)
2025
%y
Year (2 digits)
25
%m
Month (01-12)
06
%-m
Month (1-12, no leading zero)
6
%d
Day (01-31)
15
%-d
Day (1-31, no leading zero)
5
%B
Full month name
June
%b
Short month name
Jun
Date Filters
Get current date/time:
Get tomorrow's date:
(86400 is the number of seconds in a day)
Get date from 7 days ago:
(604800 is the number of seconds in 7 days)
Advanced Query Examples
Seasonal Campaigns
Summer birthday customers (June-August):
Holiday season customers:
Customer Engagement
Customers who haven't purchased in 90 days but are tagged:
High-value customers:
Dynamic Monthly Campaigns
First day of current month:
Last week of current month:
Query Operators
AND Operator
Customers must match all conditions:
OR Operator
Customers must match at least one condition:
NOT Operator
Exclude customers matching a condition:
Wildcards (*)
Match partial patterns:
Finds all tags starting with "birthday-"
Setting Up Customer Tags
For date-based campaigns (like birthdays), you need to tag your customers in Shopify first:
Birthday Tag Format
Recommended format: birthday-MM-DD
Examples:
birthday-01-15 (January 15)
birthday-06-30 (June 30)
birthday-12-25 (December 25)
How to Tag Customers
Go to Shopify Admin → Customers
Select a customer
In the Tags field, add: birthday-MM-DD (replace with actual date)
Save the customer
Tip: You can bulk tag customers by:
Importing a CSV with tags
Using Shopify Flow
Using a third-party app
Best Practices
1. Always Test Your Query
Click the Test Query button before saving. This prevents errors and shows you how many customers will be targeted.
2. Start Simple
Begin with basic queries and add complexity gradually: