Query segments let you define precise rules that decide which contacts are included in a segment. By combining fields, behaviors, and other criteria with clear logic, you can build dynamic audiences that update automatically as contacts match or no longer match your rules.
Quick Reference (Advanced Users) - Click to Expand
- Create a new segment, then set Method to Query.
- Use the Match option for each group to choose All (AND) or Any (OR).
- Keep one group for your core audience (for example, region or customer type).
- Add extra groups for engagement or exclusions to refine the audience.
- Test your logic by saving the segment and checking that the results match your expectations.
When to Use the Query Method
Use a Query segment when you need more than a simple search or manual selection. Query segments are best when:
- You want the segment to update automatically as data changes.
- You need to combine several conditions, such as profile fields and behaviors.
- You want to group contacts for specific automated programs or campaigns.
How Query Logic Works
Query segments are built from:
- Rows that describe individual conditions. Each row includes a data source (such as Profile or Behavior), a field, an operator, and a value.
- Groups that contain one or more rows. Each group has a match setting that controls whether contacts must match all rows in that group or any row in that group.
At a high level:
- All of these means AND logic for that group. Contacts must satisfy every row in the group.
- Any of these means OR logic for that group. Contacts can satisfy any one of the rows to be included.
Build a Basic Query Segment
The steps below describe a common pattern you can reuse for many scenarios.
- Create a segment and select Query as the segmentation method.
- Set the group to match All of these.
- Add your core audience rules, for example:
- Profile › Country › equals ›
United Kingdom - Profile › Lifecycle Stage › equals ›
Prospect
- Profile › Country › equals ›
- Add a behavior rule:
- Behavior › Email messages › clicked any message in the last 30 days
- Save the segment and confirm that the resulting contact count looks reasonable.
In this example, the segment returns contacts who are prospects in the UK and who have recently clicked any email.
AND vs OR Patterns
Use AND logic for “must have all” rules
Use All of these when every condition is required. For example:
- Industry is Education
- Job Role contains Teacher
- Clicked any email in the last 14 days
With an “All of these” group, a contact must match the industry, role, and recent click activity to be included.
Use OR logic for “any of these is fine” options
Use Any of these when there are several acceptable options. For example, you might want contacts in any of three regions:
- Region equals UK
- Region equals Ireland
- Region equals Nordics <>