Ads News
by Jordan Rogers-Smith
April 19
Announcing Ad Rules Engine

The Ad Rules engine is a central rule management service that helps you manage ads more easily, efficiently and intelligently. Typically you periodically query Marketing API to monitor the status of ads, and manually take action on certain conditions. Since most conditions can be quantified as logical expressions, we can automate this management.

These rules engine API’s are in open beta. Please email rulesengine@fb.com with your app ID to request access.

There are two forms of rules. Schedule Based, which are evaluated on a set interval or Trigger Based, which check if the rule condition is true each time the ads insights or metadata changes. You should set up webhooks for near-real time notifications when your rules are triggered, see Webhooks Guide. Then you can set up your Ad Rules, which are are standalone objects stored and created at act_xxxxxx/adrules_library. They have three parts:

  • name - rules name,
  • evaluation_spec - determines objects to evaluate the rule against,
  • execution_spec- the action to be applied to the objects who pass the condition,

Below is an example of a trigger rule that sends wedbhook pings for Ads under the Ad Sets with ID 101, 102, or 103 that have had more than 10000 impressions in the last 7 days and satisfy the trigger of having a CPC greater than $0.10.

curl \
-F 'name=Rule 1' \
-F 'evaluation_spec={
      "evaluation_type" : "TRIGGER",
      "trigger" : {
        "type": "STATS_CHANGE",
        "field": "cpc",
        "value": 10,
        "operator": "GREATER_THAN",
      },
      "filters" : [
       {
         "field": "entity_type",
         "value": "AD",
         "operator": "EQUAL"
       },
       {
         "field": "time_preset",
         "value": "LAST_7_DAYS",
         "operator": "EQUAL"
       },
       {
         "field": "adset.id",
         "value": [101, 102, 103],
         "operator": "IN"
       },
       {
         "field": "impressions",
         "value": 10000,
         "operator": "GREATER_THAN"
       }
     ]
   }' \
-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 the different parameters and actions available, see Ads Rules Engine.