Scriptlytics
  • Introduction
    • Welcome to the community
  • Account level scripts
    • Account overview (all time)
    • Account performance (date range)
    • Account performance (daily export)
    • Account performance (last 90 days)
    • Account search query optimizer
    • Account search query optimizer (yesterday)
    • Call asset scheduling
    • Account keyword optimizer (date range)
    • Account keyword optimizer (last 90 days)
    • Match type report (last 360 days)
    • Negative keyword list
  • Campaign level scripts
    • Campaign performance (date range)
    • Campaign performance (daily export)
    • Campaign performance (last 90 days)
    • Multiple campaign performance (last 90 days)
    • Ad groups (date range)
    • Ad groups (last 30 days)
    • Keyword optimizer (date range)
    • Keyword optimizer (last 30 days)
    • Impressions heatmap (date range)
    • Impressions heatmap (last 30 days)
    • Clicks heatmap (date range)
    • Clicks heatmap (last 30 days)
    • CTR heatmap (date range)
    • CTR heatmap (last 30 days)
    • Conversions heatmap (last 30 days)
    • Conversions heatmap (date range)
    • Conversion rate heatmap (last 30 days)
    • Conversion rate heatmap (date range)
    • CPC heatmap (last 30 days)
    • CPC heatmap (date range)
  • pmax scripts
    • Pmax segmentation
    • Pmax search query optimizer
    • Pmax search query optimizer (all time)
  • Call reports
    • Call report (date range)
    • Call report (evergreen)
  • Bulk edit and actions
    • Bulk upload template
    • Swap Base URL's
    • Copy campaign and swap base URL's
  • Alerts and notifications
    • Zero spend alert
  • MCC scripts
    • MCC account performance export
    • Revised MCC account performance export
  • Search ads
    • Keyword match optimizer
  • Google sheets
    • Remove the following keywords
    • Remove keywords that don't contain
    • Remove keywords that don't contain and create negative keyword list
  • Product title modification
Powered by GitBook
On this page
  1. Alerts and notifications

Zero spend alert

****** THIS SCRIPT IS NOT COMPLETE ****** This script is designed to monitor Google Ads campaigns (that are enabled) for any that have not incurred any expenses on the previous day. It starts by determining yesterday's date relative to the current date and formats this date in a specific string format suitable for querying Google Ads. It then retrieves all enabled campaigns for that date range, which, in this case, is just the single day (yesterday). For each campaign, it checks the advertising spend; if a campaign had zero spend, its name is added to a list of no-spend campaigns. If there are any campaigns in this list by the end of the script, it constructs an email notification. This notification includes a subject line indicating it's an alert for Google Ads campaigns with zero spend, and the message body lists the names of all campaigns that had no spend on the previous day. The email is then sent to one or more specified recipients, alerting them to these no-spend campaigns. The script can be customized to send the notification to multiple email recipients either by including them all in a single email or by sending separate emails to each.

To set up this script, follow these steps:

  1. Open your Google Ads account.

  2. Go to the "Tools & Settings" menu and select "Scripts".

  3. Click the "Create" or "+" button to create a new script.

  4. Copy and paste the following script.

function main() {
  var today = new Date();
  var yesterday = new Date(today);
  yesterday.setDate(today.getDate() - 1);
  var dateString = Utilities.formatDate(yesterday, AdsApp.currentAccount().getTimeZone(), 'yyyyMMdd');
  
  // Retrieve the current account name
  var accountName = AdsApp.currentAccount().getName();
  
  var campaigns = AdsApp.campaigns()
    .withCondition("Status = ENABLED")
    .forDateRange(dateString, dateString)
    .get();
  
  var noSpendCampaigns = [];
  
  while (campaigns.hasNext()) {
    var campaign = campaigns.next();
    var stats = campaign.getStatsFor(dateString, dateString);
    if (stats.getCost() == 0) {
      noSpendCampaigns.push(accountName + ": " + campaign.getName());
    }
  }
  
  if (noSpendCampaigns.length > 0) {
    var subject = 'Google Ads Zero Spend Alert';
    var message = 'The following enabled campaigns had no spend yesterday (' + dateString + ') in account ' + accountName + ':\n\n' + noSpendCampaigns.join('\n');
    // Send to two emails, separated by commas
    MailApp.sendEmail('first.email@example.com,second.email@example.com', subject, message);
  }
}


  1. Add the emails you'd like to recieve an alert.

  2. Save the script.

  3. Review and authorize the script to access your Google Ads and Google Sheets accounts.

  4. Run the script manually for the first time to populate the initial values in the spreadsheet.

  5. (Optional) Schedule the script to run on a specific cadence (ie: daily, weekly, monthly, etc.)

Note: Ensure that you have the necessary permissions to access and modify the target Google Spreadsheet.

PreviousCopy campaign and swap base URL'sNextMCC account performance export

Last updated 12 months ago