Ad Rules Engine

A central rule management service that helps you easily, efficiently and intelligently manage ads. Without it, you must query the Marketing API to monitor an ad's performance and manually take actions on certain conditions. Since we can express most conditions as logical expressions, we can automate management two ways: using Schedule-based or Trigger-based Based rules.

New to this? Try the rules-based notification quickstart in your App Dashboard, Quickstarts.

Ad Rules

Ad Rules are standalone objects created and stored in the Ad Rules Library and minimally contain a name, an evaluation_spec and an execution_spec. This is the basic structure of a rule:

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

Facebook evaluates Trigger-based rules when Insights metrics or Object metadata field changes. We evaluate Schedule-based rules on scheduled time intervals.

Options

  • Trigger-based rules: Monitor the state of your ads in real-time. A Trigger Based Rule is evaluated as soon as its pertinent ad objects' metadata or insights data are changed.
  • Schedule-based rules: Monitor the state of your ads by checking them at a set interval to see if they meet the evaluation_spec criteria.

Components

Evaluation Spec

The main purpose of the evaluation_spec of a rule is to determine the objects upon which the rule should execute its action. Learn more.

Execution Spec

The execution_spec of a rule determines the action that applies to all objects that pass evaluation. Learn more.

Status

The status of a rule determines whether the rule should be running. There are two statuses: ENABLED and DISABLED. To temporarily turn off a rule, edit the rule and set its status to DISABLED. To reactivate a rule, edit the rule and set its status back to ENABLED. To permanently remove a rule, delete it.