Ad Rules Examples - ROAS

For ROAS related metrics, it is important to use a combination of filters to specify exactly how to compute the ROAS metric. Important filters include attribution_window, time_preset (lookback window), and hours_since_creation here.

For example, say that we want to compute 7D Click Mobile App Purchase ROAS, but we only want 7 days of mature data. In this case, we want to use an attribution_window of 7D_CLICK, with a time_preset of LAST_ND_14_8. This will attribute all mobile app purchase values within 7 days of users who clicked on the ad in the lookback window, which excludes the most recent 7 days since they will include immature data. If the user clicked on the ad yesterday, we do not include the user in the ROAS computation since they still have 6 days of potential purchases.

Note that by purchase values, this refers to the values of Mobile App Purchase events and Website Conversion Purchase (FB Pixel) events for the respective ROAS metrics. In the API, this would mean the purchase values of the app_custom_event.fb_mobile_purchase and offsite_conversion.fb_pixel_purchase count metrics, respectively.

Note that if the attribution window includes both click and view windows, the computed ROAS will be the sum of the values. For example, if our attribution_window is 1D_VIEW_7D_CLICK, we will take the 1D_VIEW ROAS value and 7D_CLICK ROAS value and compute the sum. This is because the two attributions are disjoint and can correctly be added together without overlap.

An optimal use of this metric will also include some time-based filter, since we need to make sure enough days have elapsed for there to be mature data. If the use case requires mature data, we recommend a filter such as hours_since_creation to ensure that the Ad Set has been running long enough.

Here's an example rule that increases budget by 20% if the 7D Click Website Purchase ROAS is greater than 0.50 (50%) for 7 days of mature data, checking once per day. Since these rules are heavily specific, they will usually apply to a specific list of Ad Sets (e.g. id = 123). Note that we also use 8*24 for hours since creation to get at least 1 full day of mature data.

curl \
-F 'name=Test Website ROAS Rule' \
-F 'schedule_spec={
     "schedule_type": "DAILY"
   }' \
-F 'evaluation_spec={
     "evaluation_type": "SCHEDULE",
     "filters": [
       {
         "field": "id",
         "value": [123],
         "operator": "IN"
       },
       {
         "field": "time_preset",
         "value": "LAST_ND_14_8",
         "operator": "EQUAL"
       },
       {
         "field": "attribution_window",
         "value": "7D_CLICK",
         "operator": "EQUAL"
       },
       {
         "field": "hours_since_creation",
         "value": 192,
         "operator": "GREATER_THAN"
       },
       {
         "field": "website_purchase_roas",
         "value": 0.50,
         "operator": "GREATER_THAN"
       }
     ]
   }' \
-F 'execution_spec={
     "execution_type": "CHANGE_BUDGET",
     "execution_options": [
       {
         "field": "change_spec",
         "value": {
           "amount": 20,
           "unit": "PERCENTAGE"
         },
         "operator": "EQUAL"
       },
     ]
   }' \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<VERSION>/<AD_ACCOUNT_ID>/adrules_library

Here's an example rule that scales bid daily towards a target 1D View 1D Click Mobile App Purchase ROAS value of 0.80, with a 5% tolerance window (set by a range filter on the ROAS value). Again, we only want mature data, so we will use time presets that do not include today's data. This includes time presets such as LAST_7D and LAST_14D.

curl \
-F 'name=Test Mobile App ROAS Rule' \
-F 'schedule_spec={
     "schedule_type": "DAILY"
   }' \
-F 'evaluation_spec={
     "evaluation_type": "SCHEDULE",
     "filters": [
       {
         "field": "id",
         "value": [123],
         "operator": "IN"
       },
       {
         "field": "time_preset",
         "value": "LAST_7D",
         "operator": "EQUAL"
       },
       {
         "field": "attribution_window",
         "value": "1D_VIEW_1D_CLICK",
         "operator": "EQUAL"
       },
       {
         "field": "hours_since_creation",
         "value": 48,
         "operator": "GREATER_THAN"
       },
       {
         "field": "mobile_app_purchase_roas",
         "value": [0.76, 0.84],
         "operator": "NOT_IN_RANGE"
       }
     ]
   }' \
-F 'execution_spec={
     "execution_type": "CHANGE_BID",
     "execution_options": [
       {
         "field": "change_spec",
         "value": {
           "amount": 0.80,
           "target_field": "mobile_app_purchase_roas"
         },
         "operator": "EQUAL"
       },
     ]
   }' \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<VERSION>/<AD_ACCOUNT_ID>/adrules_library