How-to Pause or Activate Meta (Facebook) Ads
Overview
In these instructions, we’ll focus on how to create the datasources and sql views to leverage the Alli Actions Ad Effective Status action to pause ads automatically. This can also be leveraged for the Adset Effective Status action to pause adsets, or the Campaign Effective Status action to pause campaigns.
Instructions
Create your reference sheet datasource
In your reference sheet, you need the following columns:
ad_id
(best) ORad_name
(good)Ensure
ad_id
is set to `plain text` and not number formatWe recommend including both or just ad_id, as ad_id is cleaner/simpler, and is required for activating ads
If you select
ad_id
you can skip directly to creating your queryIf you select
ad_name
you will be using core data{client}_core.social_ad
or{client}_core.social_adset
or{client}_core.social_campaign
in your SQL later on.
date
- the date you want the ad to be paused or activatedstatus
- the status you want implemented:Options are
Active
,Archived
,Deleted
, orPaused
![](../../__attachments/2093646111/image-20210429-212247.png?inst-v=9d2044ed-f5d2-41ad-960f-0e53811769aa)
USING YOUR GOOGLE SHEET TO POWER YOUR ACTION
The benefit of this method is no SQL and no report to manage. After you set this tab up fully, you will not touch it, nor should anyone else. - this is important
Create a new tab, name it appropriately (Recommended
Actions Sheet - DO NOT EDIT
).Copy the headers from your first tab here.
Rename your
status
column toeffective_status
Rename your
ad_id
(or campaign_id, adset_id, etc) column is namedid
In Cell A2, place and update this function
=FILTER(Sheet1!A:D,Sheet1!B:B,Sheet1!B:B=TODAY())
Sheet1
should be the name of your first sheet
Check your google sheet timezone
this is impactful because
TODAY()
gets the current date in the timezone. So if your action runs at 1 am eastern time on 2/10, but your google sheet is in pacific time,TODAY()
in pacific time would be 2/9 (at 10 pm). TLDR - make sure your google sheet timezone makes sense with 1) what time & timezone your action will run in, and 2) what date you put in the first tab.File > Settings > Timezone
USING SQL TO POWER YOUR ACTION
Login to Alli Data and select the client you want to create a datasource for
Navigate to Reports, select Add New Datasource, and select the datasource type (Google Sheets, Smartsheet, Airtable, etc). Give your datasource a new name.
In Advanced Settings, ensure you select
Replace
for New UploadsEnsure the
Ad Id
/Ad Name
and thestatus
columns are Numbers & LettersEnsure the
Date
column is a Date Timestamp
Save your new datasource & select Load Data
Create your SQL view
Login to Alli Data and select the client you want to create/find a datasource for
Navigate to Reporting → Reports and select New Data Report. Select the SQL option
Copy and paste the SQL Example in from below and update anything within and including
{
}
to match your client settingsClick Preview to ensure the output is as expected
Once your SQL is updated, click Publish to update the query. Name your report and give it a description and click save
Click Preview to ensure the output is as expected
Create your Action
Navigate to Alli Actions by selecting Actions then select Create Action
Filter down the list and select the Ad Effective Status Action Type
Name your action and select your authenticated account
Select Alli Data and place the name of the view you created above
Review your action setup
Save and Schedule your action to run
SQL Example: ID
replace
{reference}
with the datasource you created (ensure you remove the brackets as well)ref.status
should reference the column name of the status column in your reference datasourceref.date
should reference the column name of the date column in your reference datasource
Ad Example (assuming your column is named ad_id)
select ref.ad_id::text as id,
ref.status as effective_status
from {reference} as ref
where ref.date = current_date
Adset Example (assuming your column is named adset_id)
select ref.adset_id::text as id,
ref.status as effective_status
from {reference} as ref
where ref.date = current_date
Ad Example (assuming your column is named campaign_id)
select ref.campaign_id::text as id,
ref.status as effective_status
from {reference} as ref
where ref.date = current_date
Filled out example (Pretending my datasource you created in Create your reference sheet datasource
is named client.ad_status_google_sheet
select ref.ad_id::text as id,
ref.status as effective_status
from client.ad_status_google_sheet as ref
where ref.date = current_date
SQL Example: Ad Name (Not recommended, use ad_id if possible)
replace
{reference}
with the datasource you createdref.status
should reference the column name of the status column in your reference datasourceref.ad_name
should reference the column name of the ad name column in your reference datasourceref.date
should reference the column name of the date column in your reference datasource
replace
{client}
with your client namefb.ad_id
should reference the column name of the ad id within the facebook datasourcefb.ad_name
should reference the column name of the ad name within the facebook datasource
select distinct(fb.ad_id) as id,
ref.status as effective_status
from {reference} as ref
left join {client}_core.social_ad as fb
on ref.ad_name = fb.ad_name
where ref.date = current_date
SQL Example: Creating separate queries for activating vs pausing
You can use the same reference sheet for both activating and pausing ads, and if so we recommend leveraging the ad_id column, as new ads (that have not run yet) may not exist in your facebook datasource yet (until they receive impressions or spend)
To use the same reference sheet, if your ads pause and activate at the same time, you don’t need separate sql, but if you activate and pause ads at different times (or just want to keep the queries separate) you can use the below options.
Pausing (using Ad Name)
select distinct(fb.ad_id)::text as id,
ref.status as effective_status
from {reference} as ref
left join {facebook} as fb
on ref.ad_name = fb.ad_name
where ref.date = current_date
and status = 'Paused'
Pausing (Using Ad Id)
select ref.ad_id::text as id,
ref.status as effective_status
from {reference} as ref
where ref.date = current_date
and status = 'Paused'
Activating
select ref.ad_id::text as id,
ref.status as effective_status
from {reference} as ref
where ref.date = current_date
and status = 'Active'
Related articles
- How To Handle Common Types of Actions Issues
- How To Filter Alli Data Reports by Date to Power Actions - Tips & Tricks
- How To Run an Action One-Off with Manual File
- How To Connect your Google Sheet to Actions
- How To Set Up a Manual Upload Action
- How To Test Your Action
- How To Schedule Your Action to Run
- How To Disable or Remove an Action
- How To QA Your Action Runs
- How To View Error Messages on an Action That Ran
- How Manage Partner Platform Authentication in Actions
- How-To Add Locations to Campaigns in Google Ads
- How-to Pause or Activate Meta (Facebook) Ads
- How To Add Negative Mobile Placements in Google Ads
- How To Add Negative Keywords to Google Ads