Working with segment queries

When creating a segment, you need to specify a query that will be applied to filter your list. We support 3 query language formats: SQL-like, FIQL, JSON.

Operation

An operation consists of a contact attribute or custom attribute, an operator and a value.

Here a 2 exemples of an operation.

`email` = "[email protected]"
`birthdate` > "2000-01-01"
[email protected]
birthdate=gt=2000-01-01
{"eq": {"email": "[email protected]"}}
{"gt": {"birthdate": "2000-01-01"}}

Valid operators

The following operators are valid to use inside of an operation:

=
!=
>
>=
<
<=
LIKE // % can be used for wildcards
NOT LIKE // % can be used for wildcards
eq
neq
gt
gte
lt
lte
like // * can be used for wildcards
unlike // * can be used for wildcards
eq
neq
gt
gte
lt
lte
like // * can be used for wildcards
unlike // * can be used for wildcards

Action operation

It is also possible to use campaign's action to segment your list.

// Campaign was sent
MAILING({Campaign ID}) IS SENT

// Campaign was not sent
MAILING({Campaign ID}) IS NOT SENT

// Campaign was opened
MAILING({Campaign ID}) IS OPENED

// Campaign was not opened
MAILING({Campaign ID}) IS NOT OPENED

// At least one link in the campaign was clicked
MAILING({Campaign ID}) IS CLICKED

// No links in the campaign was clicked
MAILING({Campaign ID}) IS NOT CLICKED

// A specific link was clicked
LINK({Link ID}) IS CLICKED

// A specific link was not clicked
LINK({Link ID}) IS NOT CLICKED

// A contact has a "VIP" tag
TAG IS "VIP"

// A contact does not have a "VIP" tag
TAG IS NOT "VIP"
// Campaign was sent
mailing=sent={Campaign ID}

// Campaign was not sent
mailing=notsent={Campaign ID}

// Campaign was opened
mailing=open={Campaign ID}

// Campaign was not opened
mailing=notopen={Campaign ID}

// At least one link in the campaign was clicked
mailing=clicked={Campaign ID}

// No links in the campaign was clicked
mailing=notclicked={Campaign ID}

// A specific link was clicked
link=clicked={Link ID}

// A specific link was not clicked
link=notclicked={Link ID}

// A contact has a "VIP" tag
contact=tagged=VIP

// A contact does not have a "VIP" tag
contact=untagged=VIP
// Campaign was sent
{"sent": {"mailing": {Campaign ID}}}

// Campaign was not sent
{"notsent": {"mailing": {Campaign ID}}}

// Campaign was opened
{"open": {"mailing": {Campaign ID}}}

// Campaign was not opened
{"notopen": {"mailing": {Campaign ID}}}

// At least one link in the campaign was clicked
{"clicked": {"mailing": {Campaign ID}}}

// No links in the campaign was clicked
{"notclicked": {"mailing": {Campaign ID}}}

// A specific link was clicked
{"clicked": {"link": {Link ID}}}

// A specific link was not clicked
{"notclicked": {"link": {Link ID}}}

// A contact has a "VIP" tag
{"tagged": {"contact": "VIP"}}

// A contact does not have a "VIP" tag
{"untagged": {"contact": "VIP"}}

Nested operations

It is possible to combine multiple operations by using the keywords AND and OR. You can also add parenthesis to preserve the right priorities across operations.

Here is an exemple of a complex operation.

`email` LIKE "@cakemail.com" AND (`birthday` < "1990-01-01" OR `birthday` > "2000-01-01") AND MAILING(1234) IS OPENED
[email protected];birthdate=gt=2000-01-01
{"and": [
  {"eq": {"email": "[email protected]"}},
  {"gt": {"birthdate": "2000-01-01"}}
]}