RulesJson Criteria Syntax
The criteria is being used on a few different API end-points including journey action update and subscribers.
Schema
[
[{A}, {B}],
[{C}, {D}],
[{E}]
]
(A and B) or (C and D) or (E)
[
[
{
"type": "segments",
"operator": "belongs to",
"value": "S1"
},
{
"type": "tags",
"operator": "has this tag",
"value": "T1"
}
],
[
{
"type": "fields",
"field_id": "email",
"operator": "ends with",
"value": "@hotmail.com"
}
]
]
("Belongs to S1 segment" AND "Has T1 tag") OR ("Email ends with @hotmail.com")
Filtering By Segments
Filter people based on segment membership.
{
"type": "segments",
"operator": "...",
"value": "..."
}
operator
- one ofbelongs to
,does not belong to
value
- the segment id
Filtering By Tags
Filter people based on tag membership.
{
"type": "tags",
"operator": "...",
"value": "..."
}
operator
- one ofhas this tag
,does not have this tag
,has any of these tags
,has all of these tags
,has no tags
value
- comma separated list of tag ids
Filtering By Journeys
Filter people based on their journey enrollments.
{
"type": "journeys",
"operator": "in journey",
"value": "..."
}
operator
- one ofin journey
,completed journey
,not in journey
value
- the ID number of the target journey
Filtering By Custom Fields
Filter people based on custom field values.
{
"type": "fields",
"field_id": "...",
"operator": "...",
"value": "..."
}
field_id
- the custom field id (oremail
for email address)operator
- one ofis
,is not
,contains
,does not contain
,ends with
,begins with
,is less than
,is less than or equal to
,is greater than
,is greater than or equal to
,is set
,is not set
value
- the value to compare against
Filtering By Suppressions
Filter people based on their suppression status.
{
"type": "suppressions",
"operator": "..."
}
operator
- one ofexist
,not exist
Filtering By Website Events
Filter people based on their website events.
{
"type": "website-events",
"event": "...",
"operator": "...",
"event_parameter": "...",
"value": "..."
}
event
-pageView
,identify
,conversion
, or any custom event.operator
- one ofhappened
,did not happen
,happened in the last X days
,did not happen in the last X days
,equals
,does not equal
,contains
,does not contain
,matches regex
,does not match regex
,greater than
,less than
,is set
,is not set
event_parameter
- Website event parametervalue
- any value based on theevent_parameter
Common Event Parameters
All events include common parameters that capture details about the user's environment and the context of the event:
$browser
,$browser_language
,$browser_version
- Information about the browser used.$current_url
- The URL where the event occurred.$device
,$device_type
- Details about the device used.$os
- Operating system information.$pageTitle
,$pathname
- Document title and path.$referrer
,$referring_domain
- Referral data.$screen_height
,$screen_width
,$viewport_height
,$viewport_width
- Screen and viewport dimensions.$sent_at
- Timestamp when the event was sent.$uuid
- Unique identifier for the session.- Additional identifiers like
$dsn
,$host
,$lib
, and$lib_version
.
Event Specific Parameters
Each event type may have additional parameters:
identify
includes emailAddress andname
for user identificationconversion
tracks conversions withconversionId
,conversionName
,conversionValue
customEvent
may include arbitrary parameters likeeventName
,key1
,key2
,key3
for custom tracking.
Event Query Operators
Operations are used to query events based on certain conditions. Here are the available operations:
did happen
andhappened
- Check if an event occurred, without parameters.- Temporal operations like
happened in the last X days
ordid not happen in the last X days
require a day count asvalue
. - Comparison and match operations such as
equals
,does not equal
,contains
,does not contain
,matches regex
,does not match regex
,greater than
,less than
,is set
,is not set
utilize event_parameter and avalue
.
Example: Subscribers who haven't visited the homepage
{
"type": "website-events",
"event": "pageView",
"operator": "does not equal",
"event_parameter": "$pageTitle",
"value": "Homepage"
}
Example: Page views in the last 30 days
{
"type": "website-events",
"event": "pageView",
"operator": "did not happen in the last X days",
"event_parameter": "",
"value": "30"
}
Example: Identifications with a specific email address
{
"type": "website-events",
"event": "identify",
"operator": "contains",
"event_parameter": "emailAddress",
"value": "@gmail.com"
}
Example: Specific conversion events made by visitors
{
"type": "website-events",
"event": "conversion",
"operator": "greater than",
"event_parameter": "conversionValue",
"value": "50"
}
Example: Custom event based filtering
{
"type": "website-events",
"event": "customEvent",
"operator": "matches regex",
"event_parameter": "key1",
"value": "^abc.*"
}
Example: Filtering PageViews with a property
{
"type": "website-events",
"event": "pageView",
"operator": "equals",
"event_parameter": "name",
"value": "test name"
}
Example: Filtering PageViews
{
"type": "website-events",
"event": "pageView",
"operator": "happened",
"event_parameter": "",
"value": ""
}
Filtering By Campaign Events
Filter people based on campaign events.
{
"type": "campaign-events",
"operator": "...",
"value": "..."
}
operator
- one ofopened
,not opened
,clicked
,not clicked
,unsubscribed
,complained
,not complained
,bounced
,not bounced
,delivered
,not delivered
,queued-recipients
,failed
value
- target campaign ID
Filtering By Journey Email Action Events
Filter people based on journey email action activities.
{
"type": "journey-email-action",
"operator": "opened",
"journey-id": "...",
"value": "..."
}
operator
- one ofopened
,not opened
,clicked
,not clicked
,unsubscribed
,complained
,not complained
,bounced
,not bounced
journey-id
- Target journey ID.value
- must beActionID
of the journey.
Example Rules and Rendered Queries
A
[
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"A"}
]
]
`EmailAddress` LIKE '%A%'
A AND B
[
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"A"},
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"B"}
]
]
`EmailAddress` LIKE '%A%' and `EmailAddress` LIKE '%B%'
A OR B
[
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"A"}
],
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"B"}
]
]
((`EmailAddress` LIKE '%A%') or (`EmailAddress` LIKE '%B%'))
(A AND B) OR (B AND C)
[
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"A"},
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"B"}
],
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"C"},
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"D"}
]
]
((`EmailAddress` LIKE '%A%' and `EmailAddress` LIKE '%B%') or (`EmailAddress` LIKE '%C%' and `EmailAddress` LIKE '%D%'))
(A AND B) OR (B AND C) OR E
[
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"A"},
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"B"}
],
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"C"},
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"D"}
],
[
{"type":"fields","field_id":"EmailAddress","operator":"contains","value":"E"}
]
]
((`EmailAddress` LIKE '%A%' and `EmailAddress` LIKE '%B%') or (`EmailAddress` LIKE '%C%' and `EmailAddress` LIKE '%D%') or (`EmailAddress` LIKE '%E%'))