User filters

User filters are used in the method of obtaining a list of leads (not all users, but only the required subset).

We have a visual filter editor on the Leads page. This article describes the syntax.

Example:

{
  "type": "and",
  "filters": [
    {
      "property_name": "$name",
      "type": "known",
      "value": {}
    }
  ]
}

A filter is a JSON object that contains two fields: type (filter type: and or or) and an array of filters (array of filters directly).

When using the and type, a user satisfies the filter, if he satisfies all filters. When or — if he satisfies at least one of the filters.


Filter types

For now these filter types are supported:

General:

Numbers:

String:

Boolean:

Date:

List:


Contains any value

Universal for all types. Name contains any value:

{
  "type": "known",
  "property_name": "$name",
  "value": {}
}

Undefined

Universal for all types. Name is undefined:

{
  "type": "unknown",
  "property_name": "$name",
  "value": {}
}

More than

Number of sessions is more than 5:

{
  "type": "gt",
  "property_name": "$sessions",
  "value": {"value": 5}
}

More than or undefined

Number of orders is more than 5 or undefined:

{
  "type": "gt_or_unknown",
  "property_name": "orders",
  "value": {"value": 4}
}

Less than

Number of sessions is less than 5:

{
  "type": "lt",
  "property_name": "$sessions",
  "value": {"value": 5}
}

Less than or undefined

Number of orders is less than 5 or undefined:

{
  "type": "lt_or_unknown",
  "property_name": "orders",
  "value": {"value": 5}
}

In range

Number of sessions in range from 2 to 5 (including gaps):

{
  "type": "range",
  "property_name": "$sessions",
  "value": {"value1": 2, "value2": 5}
}

Equal (for numbers)

Number of sessions equals 5:

{
  "type": "eq",
  "property_name": "$sessions",
  "value": {"value": 5}
}

Unequal (for numbers)

Number of sessions is unequal to 5:

{
  "type": "neq",
  "property_name": "$sessions",
  "value": {"value": 5}
}

Equal (for string)

Name equals "Maks" (case insensitive):

{
  "type": "str_eq",
  "property_name": "$name",
  "value": {"value": "Maks"}
}

Unequal (for string)

Name is not equal to "Maks" (case insensitive):

{
  "type": "str_neq",
  "property_name": "$name",
  "value": {"value": "Maks"}
}

Contains (for string)

Name contains "mak" (case insensitive). Acceptable number of symbols in value: from 3 to 15 (including gaps):

{
  "type": "str_contains",
  "property_name": "$name",
  "value": {"value": "mak"}
}

Does not contain (for string)

Name does not contain "mak" (case insensitive). Acceptable number of symbols in value: from 3 to 15 (including gaps):

{
  "type": "str_notcontains",
  "property_name": "$name",
  "value": {"value": "mak"}
}

True (boolean)

Property “unsubscribed from emails” is true:

{
  "type": "bool_true",
  "property_name": "$email_unsubscribed",
  "value": {}
}

False (boolean)

Property “unsubscribed from emails” is false:

{
  "type": "bool_false",
  "property_name": "$email_unsubscribed",
  "value": {}
}

More than (date)

Date of last reply is more than 12 days ago:

{
  "type": "daysmore",
  "property_name": "$last_reply",
  "value": {
    "value": 12,
    "unit": "days"
  }
}

unit field contains measures(units) of value.

Units can be: minutes, hours, days, weeks.

More than or undefined (date)

Date of last reply is more than 12 days ago or undefined (user has never replied):

{
  "type": "daysmore_or_unknown",
  "property_name": "$last_reply",
  "value": {
    "value": 12,
    "unit": "days"
  }
}

unit field contains measures(units) of value.

Units can be: minutes, hours, days, weeks.

Less than (date)

Date of last reply is less than 12 days ago:

{
  "type": "daysless",
  "property_name": "$last_reply",
  "value": {
    "value": 12,
    "unit": "days"
  }
}

unit field contains measures(units) of value.

Units can be: minutes, hours, days, weeks.

Less than or undefined (date)

Date of last reply is less than 12 days ago or undefined (user has never replied):

{
  "type": "daysless_or_unknown",
  "property_name": "$last_reply",
  "value": {
    "value": 12,
    "unit": "days"
  }
}

unit field contains measures(units) of value.

Units can be: minutes, hours, days, weeks.

Contains (for lists)

Custom property apps contains MyTestSite item

{
  "type": "lcontains",
  "property_name": "apps",
  "value": {
    "value": "MyTestSite"
  }
}

Example

Name contains any value and email contains "gmail.com":

{
  "type": "and",
  "filters": [
    {
      "property_name": "$name",
      "type": "known",
      "value": {}
    },
    {
      "property_name": "$email",
      "type": "str_contains",
      "value": {"value": "gmail.com"}
    }
  ]
}

Number of sessions is more than 20 or last reply is less than an hour ago:

{
  "type": "or",
  "filters": [
    {
      "property_name": "$sessions",
      "type": "gt",
      "value": {"value": 20}
    },
    {
      "property_name": "$last_reply",
      "type": "daysless",
      "value": {"value": 1, "unit": "hours"}
    }
  ]
}