Rule Template: Change Facebook Ad Status

This automation lets change Facebook ads’ status to ACTIVE or PAUSED based on a set of conditions.

JSON Recipe

Import the automation recipe(s) into your own account. Don’t know how? Learn here.

Rule: Facebook | Ad | Change Status
{"name":"Template: Ad | Change Status","description":"A blank recipe","nodes":{"start_1":{"type":"start","logging_enabled":false,"error_rules":[],"x":11,"y":595},"stop_1":{"type":"stop","logging_enabled":false,"error_rules":[],"x":27,"y":664},"delay_to_1":{"type":"delay_to","logging_enabled":false,"error_rules":[],"x":158,"y":516,"inputs":{"time":{"export_enabled":true,"data":"07:00:00+00:00"},"weekdays":{"export_enabled":true,"data":["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]}}},"fb_fetch_adset_ids_v2_1":{"type":"fb_fetch_adset_ids_v2","logging_enabled":false,"error_rules":[],"x":300,"y":142,"group":"group_1","inputs":{"effective_status":{"export_enabled":true,"data":["ACTIVE"]},"is_completed":{"export_enabled":true,"data":false}}},"patch_json_list_v3_1":{"type":"patch_json_list_v3","logging_enabled":false,"error_rules":[],"x":580,"y":296,"group":"group_2","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/root","value":{}},{"op":"move","from":"/id","path":"/root/id"},{"op":"add","path":"/root/status","value":"{{inputValue(\"\")}}"},{"op":"move","from":"/root","path":""}]}},"outputs":{"patched":{"title":"patched","description":"Triggers when the patching is done"}}},"input_string_1":{"type":"input_string","logging_enabled":false,"error_rules":[],"x":214,"y":555,"group":"group_2","inputs":{"string":{"export_enabled":true,"data":"PAUSED"}},"outputs":{"string":{"title":"status","description":"A string to input"}}},"filter_v2_1":{"type":"filter_v2","logging_enabled":false,"error_rules":[],"x":721,"y":253,"group":"group_3","inputs":{"filters":{"export_enabled":true,"data":[{"operator":"\u003e","pointer":"/spend","value":100},{"operator":"\u003c","pointer":"/roas","value":0.9}]}}},"patch_json_v3_1":{"type":"patch_json_v3","logging_enabled":false,"error_rules":[],"x":1690,"y":337,"group":"group_4","inputs":{"patches":{"export_enabled":true,"data":[{"op":"replace","path":"/0/text/text","value":"Ad ID: {{inputValue(\"/ad_id\")}}\nSpend: {{inputValue(\"/ad_spend\")}}\nOrders: {{inputValue(\"/orders\")}}\nGross Sales: {{inputValue(\"/gross_sales\")}}\nROAS: {{inputValue(\"/roas\")}}\n\nAd Account ID: {{inputValue(\"/ad_account_id\")}}\nCampaign ID: {{inputValue(\"/ad_campaign_id\")}}\nAdset ID: {{inputValue(\"/ad_group_id\")}}"},{"op":"replace","path":"/0/accessory/url","value":"https://adsmanager.facebook.com/adsmanager/manage/ads?act={{inputValue(\"/ad_account_id\")}}\u0026selected_adset_ids={{inputValue(\"/ad_group_id\")}}\u0026selected_campaign_ids={{inputValue(\"/ad_campaign_id\")}}\u0026selected_ad_ids={{inputValue(\"/ad_id\")}}"}]},"data":{"export_enabled":true,"data":[{"type":"section","text":{"type":"mrkdwn","text":""},"accessory":{"type":"button","text":{"type":"plain_text","text":"Ads Manager","emoji":true},"value":"click_me_123","url":"","action_id":"button-action"}}]}}},"slack_notifier_v2_1":{"type":"slack_notifier_v2","logging_enabled":false,"error_rules":[],"x":1057,"y":280,"group":"group_4","inputs":{"thread_ts":{"export_enabled":true}}},"for_each_v2_1":{"type":"for_each_v2","logging_enabled":false,"error_rules":[],"x":1373,"y":307,"group":"group_4"},"patch_json_list_v3_2":{"type":"patch_json_list_v3","logging_enabled":false,"error_rules":[],"x":402,"y":464,"group":"group_5","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/rule_name","value":"{{inputValue('/name')}}"},{"op":"add","path":"/timestamp_los_angeles","value":"{{formatTime(timeNow(\"America/Los_Angeles\"), \"%Y-%m-%d %H:%M:%S\")}}"}]}}},"patch_json_v3_2":{"type":"patch_json_v3","logging_enabled":false,"error_rules":[],"x":767,"y":278,"group":"group_4","inputs":{"patches":{"export_enabled":true,"data":[{"op":"replace","path":"/0/text/text","value":"Rule applied: {{inputValue('/name')}}"}]},"value":{"title":"rule_name","description":"A value that can be used in patches"},"data":{"export_enabled":true,"data":[{"type":"section","text":{"type":"mrkdwn","text":""}}]}}},"trigger_relay_1":{"type":"trigger_relay","logging_enabled":false,"error_rules":[],"x":1417,"y":694,"group":"group_4"},"slack_select_conversation_id_1":{"type":"slack_select_conversation_id","logging_enabled":false,"error_rules":[],"x":655,"y":79,"group":"group_4","inputs":{"conversation_id":{"export_enabled":true}}},"slack_notifier_v2_2":{"type":"slack_notifier_v2","logging_enabled":false,"error_rules":[],"x":2010,"y":385,"group":"group_4"},"map_any_to_table_rows_1":{"type":"map_any_to_table_rows","logging_enabled":false,"error_rules":[],"x":1545,"y":469,"group":"group_5","inputs":{"add_header":{"export_enabled":true,"data":true},"mapping":{"export_enabled":true,"data":{"A":"/timestamp_los_angeles","B":"/rule_name","C":"/ad_account_id","D":"/ad_campaign_id","E":"/ad_group_id","F":"/ad_id","G":"/action","H":"/ad_spend","I":"/orders","J":"/gross_sales","K":"/roas"}},"schema":{"export_enabled":true,"data":"any_list"}}},"data_relay_1":{"type":"data_relay","logging_enabled":false,"error_rules":[],"x":228,"y":414,"group":"group_3","inputs":{"data":{"title":"items","description":"Data to relay"}}},"if_v2_1":{"type":"if_v2","logging_enabled":false,"error_rules":[],"x":254,"y":293,"group":"group_4","inputs":{"b":{"export_enabled":true,"data":[]},"condition":{"export_enabled":true,"data":"not_equal"}}},"patch_json_list_v3_3":{"type":"patch_json_list_v3","logging_enabled":false,"error_rules":[],"x":705,"y":466,"group":"group_5","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/action","value":"Set status to '{{inputValue('')}}'"}]},"value":{"title":"status","description":"A value that can be used in patches"}}},"patch_json_v3_3":{"type":"patch_json_v3","logging_enabled":false,"error_rules":[],"x":968,"y":479,"group":"group_5","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/timestamp_los_angeles","value":"{{formatTime(timeNow(\"America/Los_Angeles\"), \"%Y-%m-%d %H:%M:%S\")}}"},{"op":"add","path":"/rule_name","value":"{{inputValue('/name')}}"},{"op":"add","path":"/action","value":"Ran rule."}]},"data":{"export_enabled":true,"data":{}}}},"patch_json_v3_4":{"type":"patch_json_v3","logging_enabled":false,"error_rules":[],"x":1261,"y":482,"group":"group_5","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/-","value":"{{inputValue(\"\")}}"}]}}},"google_sheets_append_table_rows_v3_1":{"type":"google_sheets_append_table_rows_v3","logging_enabled":false,"error_rules":[],"x":1827,"y":494,"group":"group_5","inputs":{"spreadsheet_id":{"export_enabled":true},"range":{"export_enabled":true,"data":"log"}}},"data_relay_2":{"type":"data_relay","logging_enabled":false,"error_rules":[],"x":13,"y":344,"group":"group_4","inputs":{"data":{"title":"items","description":"Data to relay"}}},"join_data_1":{"type":"join_data","logging_enabled":false,"error_rules":[],"x":916,"y":344,"group":"group_1","inputs":{"conditions":{"export_enabled":true,"data":[{"a":"/id","b":"/ad_id"}]},"target":{"export_enabled":true,"data":""}}},"filter_v2_2":{"type":"filter_v2","logging_enabled":false,"error_rules":[],"x":1164,"y":404,"group":"group_1","inputs":{"filters":{"export_enabled":true,"data":[{"operator":"!=","pointer":"/spend","value":0}]}}},"patch_json_list_v3_4":{"type":"patch_json_list_v3","logging_enabled":false,"error_rules":[],"x":1434,"y":397,"group":"group_1","inputs":{"patches":{"export_enabled":true,"data":[{"op":"add","path":"/roas","value":"{{\nif(\n    equals(inputData(\"/purchase_roas_omni_purchase\"), null),\n    0,\n    cast(inputData(\"/purchase_roas_omni_purchase\"),\"float\")\n)\n}}"},{"op":"add","path":"/cost_per_purchase","value":"{{\nif(\n    equals(inputData(\"/cost_per_action_type_purchase\"), null),\n    0,\n    cast(inputData(\"/cost_per_action_type_purchase\"),\"float\")\n)\n}}"},{"op":"add","path":"/cpc","value":"{{\nif(\n    equals(inputData(\"/cost_per_outbound_click_outbound_click\"), null),\n    0,\n    cast(inputData(\"/cost_per_outbound_click_outbound_click\"),\"float\")\n)\n}}"},{"op":"add","path":"/ctr","value":"{{\nif(\n    equals(inputData(\"/outbound_clicks_ctr_outbound_click\"), null),\n    0,\n    cast(inputData(\"/outbound_clicks_ctr_outbound_click\"),\"float\")\n)\n}}"},{"op":"add","path":"/outbound_clicks","value":"{{\nif(\n    equals(inputData(\"/outbound_clicks_outbound_click\"), null),\n    0,\n    cast(inputData(\"/outbound_clicks_outbound_click\"),\"integer\")\n)\n}}"},{"op":"add","path":"/purchases","value":"{{\nif(\n    equals(inputData(\"/actions_purchase\"), null),\n    0,\n    cast(inputData(\"/actions_purchase\"),\"integer\")\n)\n}}"},{"op":"add","path":"/purchase_value","value":"{{\nif(\n    equals(inputData(\"/action_values_omni_purchase\"), null),\n    0,\n    cast(inputData(\"/action_values_omni_purchase\"),\"float\")\n)\n}}"}]},"value":{"export_enabled":true}}},"fb_fetch_adset_ad_ids_v2_1":{"type":"fb_fetch_adset_ad_ids_v2","logging_enabled":false,"error_rules":[],"x":583,"y":203,"group":"group_1","inputs":{"effective_status":{"export_enabled":true,"data":["ACTIVE"]}}},"fb_update_ads_1":{"type":"fb_update_ads","logging_enabled":false,"error_rules":[],"x":893,"y":374,"group":"group_2","inputs":{"batch_size":{"export_enabled":true,"data":50}}},"fb_fetch_insights_v6_1":{"type":"fb_fetch_insights_v6","logging_enabled":false,"error_rules":[],"x":513,"y":472,"group":"group_1","inputs":{"action_report_time":{"export_enabled":true,"data":"conversion"},"breakdowns":{"export_enabled":true},"action_breakdowns":{"export_enabled":true},"filters":{"export_enabled":true},"fields":{"export_enabled":true,"data":["account_id","account_name","spend","impressions","actions","ad_name","ad_id","adset_id","adset_name","campaign_name","campaign_id","action_values","purchase_roas","cost_per_action_type","cost_per_outbound_click","outbound_clicks","outbound_clicks_ctr","cpm"]},"use_unified_attribution_setting":{"export_enabled":true,"data":true},"level":{"export_enabled":true,"data":"ad"},"action_attribution_windows":{"export_enabled":true,"data":["default"]},"time_increment":{"export_enabled":true,"data":"all_days"},"date_range":{"export_enabled":true,"data":"last_3d"}}},"fb_select_ad_account_ids_v2_1":{"type":"fb_select_ad_account_ids_v2","logging_enabled":false,"error_rules":[],"x":58,"y":417,"group":"group_1","inputs":{"ad_account_ids":{"export_enabled":true}}},"fetch_automation_details_1":{"type":"fetch_automation_details","logging_enabled":false,"error_rules":[],"x":106,"y":463,"group":"group_5"},"fetch_automation_details_2":{"type":"fetch_automation_details","logging_enabled":false,"error_rules":[],"x":535,"y":339,"group":"group_4"}},"edges":[{"id":"delay_to_1.delayed:fb_fetch_adset_ids_v2_1.fetch","points":[]},{"id":"input_string_1.string:patch_json_list_v3_1.value","points":[]},{"id":"start_1.start:delay_to_1.start","points":[]},{"id":"slack_notifier_v2_1.sent:for_each_v2_1.start","points":[]},{"id":"slack_notifier_v2_1.thread_ts:slack_notifier_v2_2.thread_ts","points":[]},{"id":"slack_notifier_v2_2.sent:for_each_v2_1.next","points":[]},{"id":"for_each_v2_1.do:patch_json_v3_1.patch","points":[]},{"id":"for_each_v2_1.item:patch_json_v3_1.value","points":[]},{"id":"patch_json_v3_1.patched:slack_notifier_v2_2.send","points":[]},{"id":"if_v2_1.false:trigger_relay_1.relay","points":[]},{"id":"for_each_v2_1.done:trigger_relay_1.relay","points":[]},{"id":"patch_json_v3_1.data:slack_notifier_v2_2.blocks","points":[]},{"id":"map_any_to_table_rows_1.rows:google_sheets_append_table_rows_v3_1.rows","points":[]},{"id":"map_any_to_table_rows_1.mapped:google_sheets_append_table_rows_v3_1.append","points":[]},{"id":"patch_json_list_v3_2.data_list:patch_json_list_v3_3.data_list","points":[]},{"id":"patch_json_list_v3_2.patched:patch_json_list_v3_3.patch","points":[]},{"id":"patch_json_list_v3_3.patched:patch_json_v3_3.patch","points":[]},{"id":"patch_json_list_v3_3.data_list:patch_json_v3_4.data","points":[]},{"id":"patch_json_v3_3.data:patch_json_v3_4.value","points":[]},{"id":"patch_json_v3_3.patched:patch_json_v3_4.patch","points":[]},{"id":"patch_json_v3_4.data:map_any_to_table_rows_1.data","points":[]},{"id":"patch_json_v3_4.patched:map_any_to_table_rows_1.map","points":[]},{"id":"google_sheets_append_table_rows_v3_1.appended:delay_to_1.start","points":[]},{"id":"input_string_1.string:patch_json_list_v3_3.value","points":[]},{"id":"data_relay_2.data:if_v2_1.a","points":[]},{"id":"slack_select_conversation_id_1.conversation_id:slack_notifier_v2_2.conversation_id","points":[]},{"id":"patch_json_v3_2.data:slack_notifier_v2_1.blocks","points":[]},{"id":"data_relay_2.data:for_each_v2_1.items","points":[]},{"id":"slack_select_conversation_id_1.conversation_id:slack_notifier_v2_1.conversation_id","points":[]},{"id":"patch_json_v3_2.patched:slack_notifier_v2_1.send","points":[]},{"id":"data_relay_1.data:filter_v2_1.items","points":[]},{"id":"patch_json_list_v3_4.data_list:data_relay_1.data","points":[]},{"id":"patch_json_list_v3_4.patched:filter_v2_1.filter","points":[]},{"id":"join_data_1.joined:filter_v2_2.filter","points":[]},{"id":"filter_v2_2.items:patch_json_list_v3_4.data_list","points":[]},{"id":"join_data_1.items:filter_v2_2.items","points":[]},{"id":"filter_v2_2.filtered:patch_json_list_v3_4.patch","points":[]},{"id":"fb_fetch_adset_ids_v2_1.fetched:fb_fetch_adset_ad_ids_v2_1.fetch","points":[]},{"id":"fb_fetch_adset_ids_v2_1.adset_ids:fb_fetch_adset_ad_ids_v2_1.adset_ids","points":[]},{"id":"fb_fetch_adset_ad_ids_v2_1.ad_ids:join_data_1.a","points":[]},{"id":"patch_json_list_v3_1.patched:fb_update_ads_1.update","points":[]},{"id":"fb_update_ads_1.updated:if_v2_1.evaluate","points":[]},{"id":"patch_json_list_v3_1.data_list:fb_update_ads_1.data_list","points":[]},{"id":"filter_v2_1.items:patch_json_list_v3_1.data_list","points":[]},{"id":"filter_v2_1.items:data_relay_2.data","points":[]},{"id":"filter_v2_1.filtered:patch_json_list_v3_1.patch","points":[]},{"id":"filter_v2_1.items:patch_json_list_v3_2.data_list","points":[]},{"id":"fb_fetch_adset_ad_ids_v2_1.fetched:fb_fetch_insights_v6_1.fetch","points":[]},{"id":"fb_select_ad_account_ids_v2_1.ad_account_ids:fb_fetch_adset_ids_v2_1.ad_account_ids","points":[]},{"id":"fb_select_ad_account_ids_v2_1.ad_account_ids:fb_fetch_insights_v6_1.ad_account_ids","points":[]},{"id":"if_v2_1.true:fetch_automation_details_2.fetch","points":[]},{"id":"fetch_automation_details_2.details:patch_json_v3_2.value","points":[]},{"id":"fetch_automation_details_2.fetched:patch_json_v3_2.patch","points":[]},{"id":"fb_fetch_insights_v6_1.insights:join_data_1.b","points":[]},{"id":"fb_fetch_insights_v6_1.fetched:join_data_1.join","points":[]},{"id":"fetch_automation_details_1.details:patch_json_list_v3_2.value","points":[]},{"id":"fetch_automation_details_1.details:patch_json_v3_3.value","points":[]},{"id":"fetch_automation_details_1.fetched:patch_json_list_v3_2.patch","points":[]},{"id":"trigger_relay_1.relayed:fetch_automation_details_1.fetch","points":[]}],"groups":{"group_4":{"title":"Send Slack Alert","description":"","x":1257,"y":306,"inputs":["if_v2_1.evaluate","slack_select_conversation_id_1.conversation_id","data_relay_2.data"],"outputs":["trigger_relay_1.relayed"]},"group_5":{"title":"Add to log","description":"","x":1533,"y":322,"inputs":["patch_json_list_v3_3.value","patch_json_list_v3_2.data_list","fetch_automation_details_1.fetch"],"outputs":["google_sheets_append_table_rows_v3_1.appended"]},"group_3":{"title":"Filter ad objects","description":"","x":680,"y":298,"inputs":["filter_v2_1.filter","data_relay_1.data"],"outputs":["filter_v2_1.items","filter_v2_1.filtered"]},"group_1":{"title":"Get data","description":"","x":408,"y":295,"inputs":["fb_fetch_adset_ids_v2_1.fetch"],"outputs":["patch_json_list_v3_4.data_list","patch_json_list_v3_4.patched"]},"group_2":{"title":"Apply changes","description":"","x":965,"y":304,"inputs":["patch_json_list_v3_1.data_list","patch_json_list_v3_1.patch"],"outputs":["input_string_1.string","fb_update_ads_1.updated"]}},"widgets":{"widget_1":{"title":"Time (Schedule)","description":"Time to run this automation. This should be at least 5 minutes after the Tableau automation.","position":100,"icon":"las la-clock","input":"delay_to_1.time"},"widget_2":{"title":"Set Status To","description":"Choose the status.","position":5,"icon":"las la-battery-half","options":[{"data":"PAUSED","title":"Paused"},{"data":"ACTIVE","title":"ACtive"}],"input":"input_string_1.string"},"widget_3":{"title":"Slack Channel","description":"Select a Slack Channel or Conversation","position":9,"input":"slack_select_conversation_id_1.conversation_id"},"widget_4":{"title":"Adset Status","description":"The rule will only be applied to adsets with this status.","position":2,"icon":"las la-battery-half","input":"fb_fetch_adset_ids_v2_1.effective_status"},"widget_5":{"title":"Conditions 1","description":"If any ad object matches this set of conditions, the rule will be applied.\n\nUse these metrics with `Greater than` and `Less than`.\n`/spend`\n`/impressions`\n`/cpm`\n`/outbound_clicks`\n`/cpc` (outbound_clicks)\n`/ctr` (outbound_clicks)\n`/purchase_value`\n`/purchases`\n`/roas`\n\nUse these fields with `Equals`, `Not equals` or `Matches Regex`:\n`/campaign_id` (string)\n`/adset_id` (string)\n`/ad_id` (string)\n`/campaign_name` (string)\n`/adset_name` (string)\n`/ad_name` (string)","position":3,"icon":"las la-filter","input":"filter_v2_1.filters"},"widget_6":{"title":"Tab","description":"Input the range to search for the table to append to","position":51,"icon":"las la-table","input":"google_sheets_append_table_rows_v3_1.range"},"widget_7":{"title":"Log Sheet","description":"Select a Google Spreadsheet file to append data to","position":50,"input":"google_sheets_append_table_rows_v3_1.spreadsheet_id"},"widget_8":{"title":"Weekdays (Schedule)","description":"The weekdays to delay the trigger","position":99,"icon":"las la-calendar-day","input":"delay_to_1.weekdays"},"widget_9":{"title":"Ad Status","description":"Only ads with this effective status will be included.","position":2,"icon":"las la-battery-half","input":"fb_fetch_adset_ad_ids_v2_1.effective_status"},"widget_10":{"title":"Ad Accounts","description":"Select one or more Facebook Accounts","position":0,"input":"fb_select_ad_account_ids_v2_1.ad_account_ids"},"widget_11":{"title":"Date Range","description":"Choose a preset or build a dynamic or fixed date range","position":3,"icon":"las la-calendar-week","input":"fb_fetch_insights_v6_1.date_range"}},"variables":{},"config":{"capture_inputs_enabled":false,"caching_enabled":false},"tags":[]}

How To

Step 1

Copy the automation into your account.

Step 2

Select the Facebook Ad Account in which you would like to pause or activate ads.

Choose which adsets and ads should be considered for this rule.

Notion image

Next, choose the conditions, date range and to whether you want to pause or activate the relevant ads.

Notion image

You can find a common set of metrics used when clicking on “Edit” of the conditions widget. If you’d like to use other metrics, custom data sources or multiple conditions, please get in touch with your CSM.

Notion image

Lastly, select a notification channel a spreadsheet for all logs and the schedule on what days of the week and time of day the automation should run.

Notion image

Step 3

Click Run Automation and wait for the automation to run at the scheduled time.

Did this answer your question?
😞
😐
🤩

Last updated on September 29, 2023