Common filtering patterns
profile.trait.Account.plan == "enterprise"
profile.trait.Account.status == "active" && profile.trait.Account.country == "US"
Use ! to invert a condition. Field access has higher precedence than !, so you don't need parentheses around a single field reference.
!profile.trait.Account.isTest && profile.trait.Account.status == "active"
Profiles without the isTest trait are excluded by this criteria. To include them, add a presence check:
(!has(profile.trait.Account.isTest) || !profile.trait.Account.isTest) && profile.trait.Account.status == "active"
Use in instead of chaining several == comparisons with ||.
profile.trait.Account.country in ["US", "CA", "MX"]
Because address references always return lists, check for membership or presence instead of comparing them directly to a string.
"jane@example.com" in profile.address.email
has(profile.address.phone)
profile.trait.Account.status == "active" && profile.address.email.exists(e, e.endsWith("@example.com"))
profile.trait.Account.lifetimeValue >= 100 && profile.trait.Account.lifetimeValue < 1000
If a trait might be missing and you want to exclude those profiles explicitly, pair the comparison with has(). This example assumes that lastPurchaseDate is stored as an RFC 3339 string. If your trait is of type timestamp, remove the timestamp() wrapper. To learn more, see Dates stored as strings.
has(profile.trait.Account.lastPurchaseDate) && timestamp(profile.trait.Account.lastPurchaseDate) > timestamp("2026-01-01T00:00:00Z")
Subtract a duration from now() to return profiles whose date attribute falls within a recent window. The following expression matches profiles with a purchase in the last 30 days (720 hours). This example assumes that lastPurchaseDate is stored as an RFC 3339 string. If your trait is of type timestamp, remove the timestamp() wrapper. To learn more, see Dates stored as strings.
timestamp(profile.trait.Account.lastPurchaseDate) > now() - duration("720h")
You can also apply arithmetic operators to combine multiple traits into a single derived condition.
profile.trait.Account.lifetimeValue - profile.trait.Account.totalRefunds > 500
profile.trait.Engagement.emailOpens + profile.trait.Engagement.smsClicks >= 10
String concatenation with + lets you build a composite value to compare against.
profile.trait.Contact.firstName + " " + profile.trait.Contact.lastName == "Jane Doe"
Use the ternary operator (?:) when the condition you want to filter on depends on another trait. It evaluates a condition and returns one Boolean when it's true and another when it's false.
profile.trait.Account.plan == "enterprise" ? profile.trait.Account.lifetimeValue > 10000 : profile.trait.Account.lifetimeValue > 1000
- Review operators and precedence when combining several conditions.
- Review the complete functions reference.