The main purpose of the evaluation_spec
of a rule is to determine the objects upon which the rule should execute its action. The evaluation_type
determines the type of evaluation method and has the following options:
Evaluation Type | Description |
---|---|
| |
|
The evaluation_spec
contains a filters
array, which allows you to further narrow the list of matched objects. For example, you can construct filters on ad, ad set and ad campaign metadata and Insights metrics. All filters are evaluated together using the AND
operator.
The filters
array contains a list of filter objects. These objects are dictionaries with keys of field
, value
, and operator
:
Filter Object Keys | Description |
---|---|
| Required. Filter field, such as Insights data or metadata |
| Required. Static filter value for the field |
| Required. Logical operator for the field |
Each filter has a list of supported logical operators. Here are the logical operators supported in SCHEDULE
and TRIGGER
rules:
Logical Operator | Value (Example) |
---|---|
| numeric (100) |
| numeric (100) |
| numeric (100) |
| numeric (100) |
| tuple ([100, 200]) |
| tuple ([100, 200]) |
| list (["1", "2", "3"]) |
| list (["1", "2", "3"]) |
| string ("ABC") |
| string ("ABC") |
| list ([1, 2, 3]) |
| list ([1, 2, 3]) |
| list ([1, 2, 3]) |
The evaluation_spec
requires a trigger
for the TRIGGER
evaluation type. The trigger contains a type and an underlying filter specification. Filter specification can be field
, value
, and operator
.
The trigger dynamically determines whether or not we should evaluate a rule, and you can have only one. See Trigger Based Rules for more information.
Below we define some special filters and general groups of filters that you can use.
time_preset
The time_preset
filter determines the time period over which we aggregate Insights metrics. Currently, we only allow one time_preset
. It applies to all stats filters in the rule, including the one used for the trigger, if present.
The only supported operator for time_preset
is EQUAL
, and this is required as long as any Insights filter or trigger is present. Trigger Based Rules only support time presets that include TODAY
because it performs real-time evaluation.
Time presets for rules can behave differently from other interfaces. Some of the time presets here include today's data. This is because today's data is critical for rules that run more frequently than daily. For other interfaces, a preset value of LAST_N_DAYS
generally does not include today's data. See the descriptions below for more details.
{ "field": "time_preset", "value": "TODAY", "operator": "EQUAL" }
Time Preset Values | Description |
---|---|
| Lifetime of the object |
| The current day starting from midnight in the ad account's timezone |
|
|
| Last 2 full days and |
| Last 6 full days and |
| Last 13 full days and |
| Last 27 full days and |
| Last 29 full days and |
| This month, including |
| This week using Monday as first day of week, including |
| This week using Sunday as first day of week, including |
| The previous full day, excluding |
| Last 2 full days, excluding |
| Last 3 full days, excluding |
| Last 7 full days, excluding |
| Last 14 full days, excluding |
| Last 28 full days, excluding |
| Last 30 full days, excluding |
| Last 14 days to Last 7 days, for ROAS |
| Last 30 days to Last 7 days, for ROAS |
| Last 60 days to Last 7 days, for ROAS |
| Last 120 days to Last 7 days, for ROAS |
| Last 180 days to Last 7 days, for ROAS |
| Lifetime to Last 7 days, for ROAS |
| Last 60 days to Last 28 days, for ROAS |
| Last 120 days to Last 28 days, for ROAS |
| Last 180 days to Last 28 days, for ROAS |
| Lifetime to Last 28 days, for ROAS |
attribution_window
The attribution_window
filter determines the lookback window over which insights metrics are aggregated. For more information, see the Insights documentation on Attribution Windows.
Currently, we only allow one attribution_window
, and it applies to all stats filters in the rule. The only supported operator for attribution_window
is EQUAL
, and this is only supported by Schedule Based Rules.
Whether specified or not, the only allowed value
for the attribution_window
is ACCOUNT_DEFAULT
.
{ "field": "attribution_window", "value": "ACCOUNT_DEFAULT", "operator": "EQUAL" }
Attribution Window Values | Description |
---|---|
| Use the account level attribution window setting |
With metadata filters, you can filter objects based on the current state of their metadata fields. These also support multi-level filtering, which means you can use prefixes to apply a metadata filter on an object's parent or grandparent. This does not affect other filters. Insights filters still apply to the normal object.
All metadata filters are supported for Scheduled Rules, but only a subset are supported for Trigger Rules.
For instance, if you want a rule that applies to ad sets of ad campaigns whose objective is WEBSITE_CLICKS
, you can include two filters:
"filters" : [ { "field": "entity_type", "value": "ADSET", "operator": "EQUAL", }, { "field": "campaign.objective", "value": "WEBSITE_CLICKS", "operator": "EQUAL" } ]
Metadata Field | Description |
---|---|
| Specific static objects for which the rule is applied. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| The object level for which the rule is applied. Supported Prefixes: none Supported Values: Supported Operators: |
| Name of the object, by partial or complete match. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Ad label ids of the object. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Objective of the ad campaign of the object. Supported Prefixes: ad campaign Supported Values: Supported Operators: |
| Start epoch time of the object. Supported Prefixes: ad set, ad campaign Supported Values: Supported Operators: |
| Stop epoch time of the object. Supported Prefixes: ad set, ad campaign Supported Values: Supported Operators: |
| Buying type of the ad campaign of the object. Supported Prefixes: ad campaign Supported Values: Supported Operators: |
| Billing event of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Optimization goal of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Autobid status of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Daily budget of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Lifetime budget of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Spend cap of the ad campaign of the object. Supported Prefixes: ad campaign Supported Values: Supported Operators: |
| Bid amount of the object. Supported Prefixes: ad, ad set Supported Values: Supported Operators: |
| Created epoch time of the object. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Updated epoch time of the object. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
Metadata Field | Description |
---|---|
| Effective statuses of the object. Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Page types for placement of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Budget reset period of the ad set of the object. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Hours since Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Estimated percentage of your ad set's budget to be spent by the end of its schedule. This uses the same mechanism as our Ad Sets, Budget Rebalancing feature, so it works with any budget type, but requires 10 hours of delivery per day. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Estimated percentage of your ad set's reach against its audience size. Supported Prefixes: ad set Supported Values: Supported Operators: |
| Seconds since the object had an effective status of Supported Prefixes: ad, ad set, ad campaign Supported Values: Supported Operators: |
| Current epoch time. Supported Prefixes: none Supported Values: Supported Operators: |
entity_type
and id
For every rule of evaluation type SCHEDULE
or TRIGGER
, you must specify either an entity_type
or id
filter.
When you specify an entity_type
filter, you determine a dynamic object level for which to apply the rule. For example, if the entity_type
is AD
, that rule automatically evaluates every new ad that added to the ad account. This happens regardless of when you create the rule. By specifying an id
filter, the rule only applies to a static list of objects.
When you specify an id
filter with no prefix, we automatically compute the object level for which to apply the rule. For example, if you want to apply a rule to ads [123, 456]
, you only need one filter field id
, value [123, 456]
, and operator IN
. In this case, entity_type
not required, since you provided an initial static list of objects, and we can compute the object level from those objects.
You can use entity_type
and id
in conjunction with multi-level filtering. For example, if you want a rule that applies to all ads under some specified ad sets, you can have an entity_type
filter of AD
and an adset.id
filter with the specified ad sets.
By default, if you do not specify an effective_status
filter, we implicitly add an effective_status
filter when evaluating the rule.
For all execution types that act upon active objects, this default filter has an operator of IN
and a value of ['ACTIVE', 'PENDING_REVIEW']
. This means the rule only evaluates objects that have or will have active delivery. For execution types that do not act upon active objects (UNPAUSE
), we add this filter with an operator of NOT_IN
and a value of ['DELETED', 'ARCHIVED']
. The default filter is an internal optimization for our execution types.
We evaluate insights filters against the current values returned from Insights API for a given time_preset
. These filters apply directly to the list or level of objects, and do not support multi-level filtering. All Insights filters support the following operators: GREATER_THAN
, LESS_THAN
, EQUAL
, IN_RANGE
, NOT_IN_RANGE
.
The units represented here are based on the currency's base in the Marketing API. For example, for USD, the base unit is the cent, which means that a value of 1000 for spent is equivalent to $10.00.
For a description of each of the fields below, see the Insights API docs. All of these filters are supported by Schedule Based Rules.
Below is a list of Insights filters and whether they are supported by Trigger Based Rules:
Insights Field | Allowed for Trigger Based Rules? |
---|---|
| No |
| No |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| No |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| No |
| Yes |
| Yes |
| Yes |
| Yes |
| Yes |
| No |
| No |
| No |
| No |
| No |
| No |
You can customize and derive advanced fields based off the insights and metadata filters above. For more information, see Advanced Evaluation Spec Filters.
Advanced filters support the following operators: GREATER_THAN
, LESS_THAN
, EQUAL
, IN_RANGE
, NOT_IN_RANGE
. They are only supported by Schedule Based Rules.
For some of the most commonly used advanced filters, we support an alias as the filter:
Advanced Field Alias | Derived From |
---|---|
|
|
|
|