object_level_prefix? } {attribution_window_prefix?} { time_preset_prefix? } { field_name }spentadset.yesterday_spent - total amount spent at the ad set level yesterdayadset.spent - total amount spent at ad set levelyesterday_spent - total amount spent yesterdaycampaign.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 clickingcampaign.lifetime_spent - total amount spent at the ad campaign level over its lifetimelifetime_campaign.spent - time preset prefixes cannot come before object level prefixeslifetime_today_spent - there cannot be two time preset prefixesad.adset.spent - there cannot be two object level prefixesyesterday.adset_spent - bad delimiterdaily_budgetadset.daily_budget - daily budget of the ad setdaily_budget - daily budgetyesterday_daily_budget - cannot use time preset prefixes on Metadata fieldsad.daily_budget - ads do not have a daily budget| Prefix | Object Type | Valid on Object Types |
|---|---|---|
ad. | Ad | Ad |
adset. | Ad Set | Ad, Ad Set |
campaign. | Campaign | Ad, Ad Set, Campaign |
| Attribution Window Prefix | Description |
|---|---|
account_default: | Use the account level attribution window setting |
default: | The Facebook default attribution window is 1 day views, 28 day clicks |
inline: | Inline attribution only (0 day views, 0 day clicks) |
1d_view: | 1 day views, 0 day clicks |
7d_view: | 7 day views, 0 day clicks |
28d_view: | 28 day views, 0 day clicks |
1d_click: | 0 day views, 1 day clicks |
7d_click: | 0 day views, 7 day clicks |
28d_click: | 0 day views, 28 day clicks |
1d_view_1d_click: | 1 day views, 1 day clicks |
7d_view_1d_click: | 7 day views, 1 day clicks |
28d_view_1d_click: | 28 day views, 1 day clicks |
1d_view_7d_click: | 1 day views, 7 day clicks |
7d_view_7d_click: | 7 day views, 7 day clicks |
28d_view_7d_click: | 28 day views, 7 day clicks |
7d_view_28d_click: | 7 day views, 28 day clicks |
28d_view_28d_click: | 28 day views, 28 day clicks |
| Prefix | Description |
|---|---|
lifetime_ | Lifetime of the object |
today_ | The current day starting from midnight in the ad account’s timezone |
last_2_days_ | YESTERDAY and TODAY |
last_3_days_ | Last 2 full days and TODAY |
last_7_days_ | Last 6 full days and TODAY |
last_14_days_ | Last 13 full days and TODAY |
last_28_days_ | Last 27 full days and TODAY |
last_30_days_ | Last 29 full days and TODAY |
this_month_ | This month, including TODAY |
this_week_mon_today_ | This week using Monday as first day of week, including TODAY |
this_week_sun_today | This week using Sunday as first day of week, including TODAY |
yesterday_ | The previous full day, excluding TODAY |
last_2d_ | Last 2 full days, excluding TODAY |
last_3d_ | Last 3 full days, excluding TODAY |
last_7d_ | Last 7 full days, excluding TODAY |
last_14d_ | Last 14 full days, excluding TODAY |
last_28d_ | Last 28 full days, excluding TODAY |
last_30d_ | Last 30 full days, excluding TODAY |
last_nd_14_8_ | Last 14 days to Last 7 days, for ROAS |
last_nd_30_8_ | Last 30 days to Last 7 days, for ROAS |
last_nd_60_8_ | Last 60 days to Last 7 days, for ROAS |
last_nd_120_8_ | Last 120 days to Last 7 days, for ROAS |
last_nd_180_8_ | Last 180 days to Last 7 days, for ROAS |
last_nd_lifetime_8_ | Lifetime to Last 7 days, for ROAS |
last_nd_60_29_ | Last 60 days to Last 28 days, for ROAS |
last_nd_120_20_ | Last 120 days to Last 28 days, for ROAS |
last_nd_180_29_ | Last 180 days to Last 28 days, for ROAS |
last_nd_lifetime_29_ | Lifetime to Last 28 days, for ROAS |
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.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)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
}
clickscpccpmcppctrfrequencyimpressionsmobile_app_purchase_roasreachresult_ratespentunique_clicksunique_impressionswebsite_purchase_roascost_per_unique_click+ - * and /. You can add constants, for example to weigh specific fields or to act as offsets.6 non-constant fields in a formula. You can have as many constants as you want.today_spent / adset.today_spent0.8 * cpc + 0.2 * cpm{ field_or_constant_1 } { + | - | * | / } { field_or_constant_2 } |
today_spent / adset.daily_budget - daily percent spendclicks / adset.clicks - ratio of clicks compared to ad set’s clickstoday_impressions / yesterday_impressions - ratio of today’s number of impressions compared to yesterday’s number of impressionstoday_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 fieldstoday_impressions/yesterday_impressions - terms must be space separated| Field | Valid on Object Types |
|---|---|
bid_amount | Ad, Adset |
daily_budget | Adset |
lifetime_budget | Adset |
spend_cap | Campaign |