Delivery Insights in Trigger-based Rules (beta)

You can set up rules that will trigger on delivery insights changes, such as an ad set exits learning phase, or an ad is penalized for bad landing page experience.

To create such rules, you need to call the endpoint of Ad Rules API, with parameters name, evaluation_spec and execution_spec.

curl \
-F 'name=Rule 1' \
-F 'evaluation_spec={
    ...
   }' \
-F 'execution_spec={
    ...
   }' \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<VERSION>/<AD_ACCOUNT_ID>/adrules_library

Example: Notify Me When My Ad Set Exits Learning Phase

Your ad sets with conversion-based optimization goal may go through learning phase. You may set up a rule to govern a specific ad set. When the ad set exits learning phase, you will be notified by the rule.

curl \
-F 'name=Notify Me When Ad Set 123 Exits Learning Phase' \
-F 'evaluation_spec={
      "evaluation_type": "TRIGGER", 
      "trigger": { 
         "type": "DELIVERY_INSIGHTS_CHANGE", 
         "field": "is_in_learning_phase", 
         "value": ["false"], 
         "operator": "IN"
      }, 
      "filters": [
        {
          "field": "id",
          "value": [123],
          "operator": "IN"
        }
      ]
   }' \
-F 'execution_spec={
      "execution_type": "NOTIFICATION"
   }' \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<VERSION>/<AD_ACCOUNT_ID>/adrules_library

You can also change the filters to apply the rule on all your ad sets:

"filters": [
  {
    "field": "entity_type",
    "value": "ADSET",
    "operator": "EQUAL"
  }
]

If you want more people receive the notification, you can specify execution_options in this way:

execution_spec={
  "execution_type": "NOTIFICATION"
  "execution_options":[
    { 
       "field": "user_ids",
       "value": [<USER_ID>s],
       "operator": "EQUAL"
    },
    {
       "field": "alert_preferences",
       "value": {
          "instant": {"trigger": "CHANGE"},
          "summary": {"trigger": "CHANGE"}
       },
       "operator":"EQUAL"
    }
  ]
}

Example: Ping My Server When My Account Has Ads Penalized

Facebook penalizes ads with landing pages where users have bad experiences. It means you can reach more audience if you can improve your landing page's experience. You may set up rules on the active ads that ping your server once the ads are penalized.

curl \
-F 'name=Notify Me When Ad Set 123 Exits Learning Phase' \
-F 'evaluation_spec={
      "evaluation_type": "TRIGGER", 
      "trigger": { 
         "type": "DELIVERY_INSIGHTS_CHANGE", 
         "field": "has_delivery_penalty", 
         "value": ["true"], 
         "operator": "IN"
      }, 
      "filters": [
        {
          "field": "entity_type",
          "value": "AD",
          "operator": "EQUAL"
        },
        {
          "field": "effective_status",
          "value": ["ACTIVE"],
          "operator": "IN"
        }
      ]
   }' \
-F 'execution_spec={
      "execution_type": "PING_ENDPOINT"
   }' \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<VERSION>/<AD_ACCOUNT_ID>/adrules_library

To learn more about PING_ENDPOINT, you can reference "Set Up Webhooks" section of the API doc.