SNAPSHOT or DYNAMIC segment processing type when creating a segment, use filters to determine which records are members of the segment.
- List filters have conditional logic that is defined by filter branches which have
ANDorORoperation types. This is defined by thefilterBranchTypeparameter. - Within these branches, there are groups of individual filters that contain logic to assess records to determine if they should be included in the segment. These are defined by the
filterTypeparameter. - Filter branches can also have nested filter branches.
Filters
There are a variety of different filter types that can be used to build out filters in a segment’s filter definition. These filters types can be used together in different combinations to construct the logic that is needed for a particular segment definition structure. HubSpot uses PASS/FAIL logic with filters to determine if a record should be in a segment. If a record passes all filters, it will be a member of the segment.Filter evaluation steps
To determine which records pass a segment’s filters, the following steps occur in order:- Select or fetch the relevant records based on the filter selected. For example, the property values for all records being evaluated for a property filter.
- If applicable, use the
pruningRefineByparameter to refine the data to a specific time range (see Refine By Operation section). - Apply the filtering rules against the refined data to determine if the records PASS or FAIL. For example, if the filter “First Name is equal to “John"" is selected, PASS all records that have “John” for their First Name contact property.
- If applicable, use the
coalescingRefineByparameter to further refine the data to a specific number of occurrences. For example, the filter “contact has filled out a form at least 2 times”.- If a
coalescingRefineByparameter is present, then PASS records that meet the number of occurrences selected. - If no
coalescingRefineByparameter is present, then records PASS or FAIL based on the criteria set in step 3.
- If a
Filter branches
A filter branch is a data structure used to build out the conditional logic of a segment’s definition. Filter branches are defined by a specific type, an operator, a list of filters, and a list of sub-branches. The filter branch’s operatorOR or AND dictate how the filter branch will be evaluated relative to the rest of the branches. The list of filters and sub-filter branches determine which records will be members of a segment.
- If the filter branch has an
ANDoperator, then the record is accepted by the branch if it passes all the branch’s filters and is accepted by all the sub-filter branches. - If the filter branch has an
ORoperator, then the record is accepted by the branch if it passes any of the branch’s filters or is accepted by any of the branch’s sub-filter branches.
Structure
All filter definitions must start with a root-levelOR filterBranchType (see filter branch types for more details). This root level OR filter branch must then have one or more AND sub-filter branches.
The root-level OR filter branch can be thought of as the parent filter branch while the AND sub-filter branches can be thought of as child filter groups. Together, these branches make up the base filter branch structure.
- JSON
POST body would be:
- JSON
OR filterBranchType parameter with two nested AND filterBranchType parameters. The nested filter branches each have one filterType that sets the criteria for the segment.
The two
filterType parameters are nested within AND filter branches, rather than directly within an OR filter branch. This structure is enforced by HubSpot’s API so that the segment’s filters can be properly rendered in the HubSpot user interface.OR filterBranchType with one nested AND filterBranchType. The AND filterBranchType has two filterType parameters, one for each criteria.
Filtering on events and associated objects
There are two special versions ofAND filterBranchType parameters:
UNIFIED_EVENTS: used to filter on events.ASSOCIATION: used to filter on records that are associated with the primary record being evaluated.
AND filter branch. For example:
Filter branch types
Below, review the differentfilterBranchType parameters that can be used to construct your segment’s filter definition structure.
OR filter branch
Begin your filter definition structure with anOR filterBranchType. It is used to apply OR conditional logic against records that are accepted by the nested AND filter branches.
OR filter branches:
- Must have one or more
ANDtype sub-filter branches. - Cannot have any filters.
OR filter branch will accept the record as well.
AND filter branch
TheAND filterBranchType is used as a nested filter branch within the parent OR filter branch. All filter definitions must have at least one AND filter branch for it to be valid. It is used to apply AND conditional logic against the records that pass evaluation as defined by its filters and have also been accepted by nested filter branches.
AND filter branches:
- Can have zero or more filters.
- Can have zero or more nested
UNIFIED_EVENTSand/orASSOCIATIONfilterBranchTypeparameters.
AND filter branch accepts a record if the record is accepted by all of its nested filter branches and the record passes all filters in the filter branch.
UNIFIED_EVENTS filter branch
TheUNIFIED_EVENTS filterBranchType can only be used as a nested filter branch within an AND filterBranchType. It is used to determine which records have or have not completed a given unified event.
UNIFIED_EVENTS type filter branches:
- Can have one or more
PROPERTYtype filters. - Cannot have any additional filter branches.
UNIFIED_EVENTS filter branch accepts a record if the record passes all filters on the filter branch and the criteria defined by the UNIFIED_EVENTS filter branch.
ASSOCIATION filter branch
TheASSOCIATION filterBranchType can only be used as a nested filter branch within an AND filterBranchType. It is used to filter on records which are associated with the primary record being evaluated.
ASSOCIATION filter branches:
- Must have one or more filters.
- Cannot have any additional nested filter branches.
ASSOCIATION filter branch accepts a record if it is accepted by all of its nested filter branches and if the record PASSES all filters of the filter branch.
You can only have additional filterBranches in the case of a CONTACT to LINE_ITEM association.
Filter types
Review the table below for the different types of filters that can be used. ThefilterType parameter is used to define the filter within the filterBranch.
Property filter operations
When filtering for records with thePROPERTY, INTEGRATION_EVENT, or SURVEY_MONKEY_VALUE filter type, you’ll include an operation object to define the parameters of the filter. This object can contain the following fields:
operationType: the type of operator that you’re filtering by (e.g.,NUMBER). Each type of property supports a set of operation types, and each operation type supports a set of operators, which you’ll define with theoperatorfield. (e.g.,ISandIS_NOT).operator: the operator that will be applied tooperationType(e.g.,ISandIS_NOT). Each property type supports a set of operators.value/values: the value or values to filter by. Some operators can accept one value, while others can accept multiple values in an array.includeObjectsWithNoValueSet: defines how the operation should treat records that do not have a value set for the defined property.- If
true, a record without a value for the evaluated property will be accepted. - If
false(default), a record without a value for the evaluated property will be rejected.
- If
firstname property value of John.
All property types operations
For any property, filters for whether the property value is known, unknown, blank, or not blank. Available operators are:IS_KNOWN, IS_UNKNOWN, IS_BLANK, IS_NOT_BLANK.
String operations
string: operations for string type properties. Available operators are:IS_EQUAL_TO,IS_NOT_EQUAL_TO,CONTAINS,DOES_NOT_CONTAIN,STARTS_WITH,ENDS_WITH,HAS_EVER_BEEN_EQUAL_TO,HAS_NEVER_BEEN_EQUAL_TO,HAS_EVER_CONTAINED,HAS_NEVER_CONTAINED.
string-comparative: compares two string properties on the same object (case-insensitive). Available operator:IS_EQUAL_TO.
Multi-string operations
Operations for multiple string values. Available operators are:IS_EQUAL_TO, IS_NOT_EQUAL_TO, CONTAINS, DOES_NOT_CONTAIN, STARTS_WITH, ENDS_WITH, CONTAINS_EXACTLY, DOES_NOT_CONTAIN_EXACTLY.
Number operations
number: operations for number type properties. Available operators are:IS_EQUAL_TO,IS_NOT_EQUAL_TO,IS_GREATER_THAN,IS_GREATER_THAN_OR_EQUAL_TO,IS_LESS_THAN,IS_LESS_THAN_OR_EQUAL_TO,HAS_EVER_BEEN_EQUAL_TO,HAS_NEVER_BEEN_EQUAL_TO.
number-ranged: filters for numbers within or outside a range using alowerBoundandupperBound. Available operators are:IS_BETWEEN,IS_NOT_BETWEEN.
number-comparative: compares two number properties on the same object. Available operators are:IS_EQUAL_TO,IS_GREATER_THAN,IS_LESS_THAN.
Boolean operations
bool: operations for boolean type properties. Can only filter for avalueoftrueorfalse. Available operators are:IS_EQUAL_TO,IS_NOT_EQUAL_TO,HAS_EVER_BEEN_EQUAL_TO,HAS_NEVER_BEEN_EQUAL_TO.
bool-comparative: compares two boolean properties on the same object. Available operators are:IS_EQUAL_TO,IS_NOT_EQUAL_TO.
Enumeration operations
Operations for enumeration type properties. Available operators are:IS_ANY_OF, IS_NONE_OF, IS_EXACTLY, IS_NOT_EXACTLY, CONTAINS_ALL, DOES_NOT_CONTAIN_ALL, HAS_EVER_BEEN_ANY_OF, HAS_NEVER_BEEN_ANY_OF, HAS_EVER_BEEN_EXACTLY, HAS_NEVER_BEEN_EXACTLY, HAS_EVER_CONTAINED_ALL, HAS_NEVER_CONTAINED_ALL.
Datetime operations
Operations for datetime properties.datetime: compares the property value to a specific datetime stamp. Available operators are:IS_EQUAL_TO,IS_BEFORE_DATE(millisecond of day’s start),IS_AFTER_DATE(last millisecond of day’s end).
datetime-comparative: compares the property value to another other datetime property on the contact record. Available operators are:IS_BEFORE,IS_AFTER.
datetime-ranged: compares the property value to a specific timestamp range. Available operators are:IS_BETWEEN,IS_NOT_BETWEEN.
datetime-rolling: compares the property value to a rolling number of days. Available operators are:IS_LESS_THAN_X_DAYS_AGO,IS_MORE_THAN_X_DAYS_AGO, IS_LESS_THAN_X_DAYS_FROM_NOW,IS_MORE_THAN_X_DAYS_FROM_NOW.
rolling-property-updated: compares the last time the property was updated to a rolling number of days. Available operators are:UPDATED_IN_LAST_X_DAYS,NOT_UPDATED_IN_LAST_X_DAYS.
property-updated-comparative: compares the last-updated timestamps of two properties on the same object. Available operators are:IS_BEFORE,IS_AFTER.
TIME_POINT and TIME_RANGED
Below, review some examples when using theTIME_POINT and TIME_RANGED parameter. These parameters can be used in both time-referenced and property-referenced requests.
Is equal to date
The request below filters for Last activity date is equal to 03/11/2024 (EDT).In Last X Number of Days
The example below filters for Last activity date is less than 3 days ago.In Next X Number of Days
The example below filters for Last activity date is less than 5 days from now.Updated or Not Updated in the Last X Days
The example below filters for Last activity date updated in last 7 days. To filter for Last activity date not updated in last 7 days, change theoperator parameter to IS_NOT_BETWEEN.
Is After Date
The example below filters for Last activity date is after 03/04/2024 (EST).Is Relative to Today
The example below can either represent Last activity date is more than x days from now or Last activity date is more than x days ago. To filter for the latter, set the value for theoffset parameter to <=0.
Is Before or After another property (value or last updated)
The example below compares the values where Last activity date is before Latest Open Lead Date. To filter for Last activity date is after Latest Open Lead Date: set theoperator value to IS_AFTER.
To filter for when the Latest Open Lead Date was updated: set the referenceType value to UPDATED_AT.
Refine by operation
There are two types of refine by operations that can be used in certain filters:pruningRefineBy: refine the data set to a particular timeframe.coalescingRefineBy: determines whether the record PASSES the filter the number of times defined.
Pruning Refine By operations
Pruning refine by operations are used to narrow down the dataset that will be used for filter evaluation by refining the dataset to a particular timeframe. Pruning refine by operations are classified into two types: relative and absolute.- Relative: narrow the dataset down based on a time offset of a number of days or weeks in the past or in the future.
- Absolute: narrow the dataset down based on the data being before or after a specific timestamp