Criteria
Learn how to use properties to filter events.
Criteria let you filter events based on their properties. Instead of just checking whether an event happened, you can narrow it down to specific details—like whether a user applied a particular coupon, viewed a page with a certain title, or abandoned a specific product.
Syntax
Criteria use operators to compare an event property (specified by its <name>) against a <value>. This enables you to create highly specific filters, such as checking if a value is greater than or less than a certain amount or if a text contains a particular word.
The general syntax for a condition is:
with /*<name>*/ /*<operator>*/ /*<value>*/
If you omit the operator, it implies the equality operator:
with /*<name>*/ /*<value>*/
This is equivalent to using the equality operator explicitly:
with /*<name>*/ equal to /*<value>*/
Multi-condition criteria
You can combine multiple criteria to create more complex filters.
To check whether all conditions are true, use the and operator:
with /*<name>*/ /*<value>*/ and with /*<name>*/ /*<value>*/
Use the or operator if you want at least one condition to be true:
with /*<name>*/ /*<value>*/ or with /*<name>*/ /*<value>*/
To shorten expressions with multiple and or or operators, you can separate conditions with commas:
with /*<name>*/ /*<value>*/, /*<name>*/ /*<value>*/ and with /*<name>*/ /*<value>*/
You can also group conditions using parentheses to control the order of evaluation:
(with /*<name>*/ /*<value>*/ and with /*<name>*/ /*<value>*/) or with /*<name>*/ /*<value>*/
Event properties
You can reference event properties by name, but in some cases, properties are nested within other properties. To access nested properties, you have a few options depending on your preference.
Here's an example using the ownership notation:
with packaging of cart's costs greater than 2
Alternatively, you can use the possessive notation:
with packaging of property costs of cart greater than 2
For a more concise option, you can use dot notation (.) to directly reference nested properties:
with cart.costs.packaging greater than 2
Building blocks
These are the parts that make up a condition:
- nameany
The name of the event property you want to filter.
- valueany
The value to compare against.
- operator
The available operators.
Examples
Compare a numeric property:
user has abandoned a cart with subtotal greater than 50
Check if two properties for equality:
user has viewed a product with name "Product One", sku "1234"
Match one condition or another:
user has viewed a product with name "Product One" or with sku "1234"
Combine multiple conditions with commas:
user has viewed a product with name "Product One", sku "1234", displayPrice 100
Group conditions with parentheses:
user has viewed a product (with name "Product One" or with name "Product Two"), with brand "Brand"