This script performs daily visibility checks on Google Ads campaigns and sends an email alert if any campaigns have received low impressions below a specified threshold.
These instructions will help you set up and run the script to perform daily campaign visibility checks.
- Google Ads account
- Google Apps Script project
- Access to the MailApp service for sending email alerts
- Open the script in your Google Apps Script project.
- In the
config
object, set the following variables:impressionThreshold
: The minimum number of impressions a campaign should have. If a campaign's impressions fall below this threshold, it will be included in the email alert. Default value is '5'.emailAddresses
: The email addresses to which the alert should be sent. Multiple email addresses can be specified by separating them with commas.
- Run the
main
function to start the script. - The script will retrieve the campaigns from the connected Google Ads account and check their visibility.
- If any campaigns have received impressions below the specified threshold, an email alert will be sent to the configured email addresses.
- The script will log the progress and completion status in the Google Apps Script logger.
The script performs the following steps:
- Selects the current Google Ads account and retrieves the account name.
- Sets the email subject dynamically based on the account name.
- Initializes the email message with an HTML table structure.
- Iterates over all the campaigns in the account.
- For each enabled campaign, retrieves the impression statistics for the current day.
- If the number of impressions is less than or equal to the specified
impressionThreshold
, the campaign is considered to have low visibility and is added to the email message. - After iterating through all campaigns, the script closes the HTML table and body tags.
- If any campaigns with low visibility are found, the script sends an email alert to the specified email addresses.
- If no campaigns with low visibility are found, the script logs a message indicating that no low impression campaigns were found.
The email alert includes the following information:
- Subject: "Daily Campaign Visibility Checks for: [Account Name]"
- Body:
- Heading: "Daily Campaign Visibility Checks"
- Paragraph: "The following campaigns have received low impressions below the Impression Threshold of [Impression Threshold] impressions:"
- Table:
- Header:
- Engine
- Account Name
- Campaign Name
- Impressions
- Rows (for each low visibility campaign):
- Engine: "Google Ads"
- Account Name: The name of the Google Ads account
- Campaign Name: The name of the campaign
- Impressions: The number of impressions received by the campaign
- Header:
- Google Apps Script
- Google Ads API
- MailApp service
- Hat tip to anyone whose code was used
- Inspiration
- etc.
Feel free to customize the README file further based on your specific project requirements and add any additional sections or information as needed.