In Schedule Based rules, it is possible to use more advanced types of filter fields.
You can set specific types of prefixes for Insights filters. This is similar to prefixes set for Metadata filters to perform multi-level filtering.
You can set an object level prefix on a filter to leverage Insights multi-level filtering. For example, an ads rule can be filtered by ad set or ad campaign performance. You can also specify attribution window and time preset prefixes on a filter. This is used to override the rule's attribution window and time preset for this particular filter.
Prefixes are optional. A field can have:
You can have all the options above, none, or any combination, as long as you keep them in that order. The field should have following format:
{ object_level_prefix?
} {attribution_window_prefix?
} { time_preset_prefix?
} { field_name
}
Below, see examples of correct and incorrect prefixed Insights fields. We also provide examples of correct and incorrect prefixed metadata fields, to show which metadata filters we support.
spent
adset.yesterday_spent
- total amount spent at the ad set level yesterday
adset.spent
- total amount spent at ad set level
yesterday_spent
- total amount spent yesterday
campaign.28d_view_1d_click:lifetime_results
- total results at the ad set level over its lifetime, with the attribution window of 28 days after viewing and 1 day after clicking
campaign.lifetime_spent
- total amount spent at the ad campaign level over its lifetime
lifetime_campaign.spent
- time preset prefixes cannot come before object level prefixes
lifetime_today_spent
- there cannot be two time preset prefixes
ad.adset.spent
- there cannot be two object level prefixes
yesterday.adset_spent
- bad delimiter
daily_budget
adset.daily_budget
- daily budget of the ad set
daily_budget
- daily budget
yesterday_daily_budget
- cannot use time preset prefixes on Metadata fields
ad.daily_budget
- ads do not have a daily budget
Prefix | Object Type | Valid on Object Types |
---|---|---|
| Ad | Ad |
| Ad Set | Ad, Ad Set |
| Campaign | Ad, Ad Set, Campaign |
Attribution Window Prefix | Description |
---|---|
| Use the account level attribution window setting |
| The Facebook default attribution window is 1 day views, 28 day clicks |
| Inline attribution only (0 day views, 0 day clicks) |
| 1 day views, 0 day clicks |
| 7 day views, 0 day clicks |
| 28 day views, 0 day clicks |
| 0 day views, 1 day clicks |
| 0 day views, 7 day clicks |
| 0 day views, 28 day clicks |
| 1 day views, 1 day clicks |
| 7 day views, 1 day clicks |
| 28 day views, 1 day clicks |
| 1 day views, 7 day clicks |
| 7 day views, 7 day clicks |
| 28 day views, 7 day clicks |
| 7 day views, 28 day clicks |
| 28 day views, 28 day clicks |
This list is the same as the list of valid time preset values, but made into lowercase and attached with a delimiter.
Prefix | 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 |
You can aggregate some Insights fields over multiple ad objects. This allows you to create filters on metrics over a specific subset of ad objects. For example, the total reach over multiple ads or the total number of clicks over different ad sets.
While some metrics such as clicks
are calculated with simple summation, other metrics such as reach
are calculated differently. Since reach
is based on unique impressions, duplicate users are removed in the aggregation over multiple ad objects.
An aggregated field takes the form of aggregate(
{ field
})
. The field
can contain attribution window and time preset prefixes. The set of ad objects to be aggregated is determined by another required filter field aggregation_id
.
aggregate(reach)
aggregate(lifetime_reach)
aggregate(daily_budget)
aggregate(adset.reach)
The aggregation_id
filter specifies which ad objects to aggregate. It only supports the IN
operator and a list of ids as its value. The ids may be of ads, ad sets, or ad campaigns, but all of them must be from the same object level.
aggregation_id
filter{ "field": "aggregation_id", "operator": "IN", "value": [1234, 5678] }, { "field": "aggregate(reach)", "operator": "GREATER_THAN", "value": 100 }
clicks
cpc
cpm
cpp
ctr
frequency
impressions
mobile_app_purchase_roas
reach
result_rate
spent
unique_clicks
unique_impressions
website_purchase_roas
cost_per_unique_click
You can set simple arithmetic expressions as a field. For example, this can be used to find the ratio between two numeric fields.
This works on Insights fields and on a subset of numeric Metadata fields. The full supported list is below.
A formula field consists of fields or constants and syntactically correct operators separated by spaces. It supports the operators +
-
*
and /
. You can add constants, for example to weigh specific fields or to act as offsets.
The fields in this case can be fully prefixed, so you can add valid object level and time preset prefixes.
We currently allow a maximum of 6
non-constant fields in a formula. You can have as many constants as you want.
today_spent / adset.today_spent
0.8 * cpc + 0.2 * cpm
{ field_or_constant_1
} { +
| -
| *
| /
} { field_or_constant_2
}
today_spent / adset.daily_budget
- daily percent spend
clicks / adset.clicks
- ratio of clicks compared to ad set's clicks
today_impressions / yesterday_impressions
- ratio of today's number of impressions compared to yesterday's number of impressions
today_impressions / aggregate(today_impressions)
- ratio of today's number of impressions compared to an aggregated number of impressions
(adset.spent - spent)
- parentheses are accepted, when receiving formulas in API responses, they will be parenthesized
(clicks + cpc + cpm + ctr + cpa + cpp) / cost_per
- cannot use more than 6
fields
today_impressions/yesterday_impressions
- terms must be space separated
Field | Valid on Object Types |
---|---|
| Ad, Adset |
| Adset |
| Adset |
| Campaign |