Skip to content
HomeScripts/budget-pacing-sentinel

Budget pacing alerts

Projects month-end spend from month-to-date totals and the recent daily rate, then emails you when the projection drifts past your tolerance or when a campaign stops spending altogether.

Try it
Shows a worked example of the output, not a run against your account.
dataLayer
Nothing yet
Google Ads Script (JavaScript)
/**
 * Goodlabs Google Ads script: budget pacing alerts
 * Schedule: Daily at 08:00
 */
var CONFIG = {
  MONTHLY_BUDGET: 5000,
  ALERT_EMAIL: "media@yourdomain.com",
  MAX_OVERPACE_PERCENT: 15
};

function main() {
  var now = new Date();
  var totalDays = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate();
  var currentDay = now.getDate();
  var daysRemaining = totalDays - currentDay;

  var campaignIterator = AdsApp.campaigns()
    .withCondition("Status = ENABLED")
    .get();

  var mtdSpend = 0;
  while (campaignIterator.hasNext()) {
    var c = campaignIterator.next();
    var stats = c.getStatsFor("THIS_MONTH");
    mtdSpend += stats.getCost();
  }

  var dailyAverage = currentDay > 0 ? (mtdSpend / currentDay) : 0;
  var projectedTotal = mtdSpend + (dailyAverage * daysRemaining);
  var diffPercent = ((projectedTotal - CONFIG.MONTHLY_BUDGET) / CONFIG.MONTHLY_BUDGET) * 100;

  Logger.log("MTD Spend: $" + mtdSpend.toFixed(2) + " | Projected: $" + projectedTotal.toFixed(2) + " (" + diffPercent.toFixed(1) + "%)");

  if (Math.abs(diffPercent) > CONFIG.MAX_OVERPACE_PERCENT && CONFIG.ALERT_EMAIL) {
    MailApp.sendEmail(
      CONFIG.ALERT_EMAIL,
      "🚨 Google Ads Pacing Alert: " + (diffPercent > 0 ? "Overpacing" : "Underpacing") + " by " + diffPercent.toFixed(1) + "%",
      "Current MTD Spend: $" + mtdSpend.toFixed(2) + "\n" +
      "Projected Month-End Spend: $" + projectedTotal.toFixed(2) + "\n" +
      "Target Monthly Budget: $" + CONFIG.MONTHLY_BUDGET + "\n\n" +
      "Recommended adjusted daily budget: $" + ((CONFIG.MONTHLY_BUDGET - mtdSpend) / Math.max(daysRemaining, 1)).toFixed(2)
    );
  }
}

How it works

  1. Calculates daily budget targets based on total monthly allowance and days in the current month.
  2. Projects month-end spend using Month-to-Date (MTD) totals and recent daily burn velocity.
  3. Measures percentage variance between projected spend and target budget.
  4. If pacing deviation exceeds ±15–20%, sends an automated email notification with adjusted daily cap recommendations.

Step-by-step installation

  1. Create a new script in Google Ads Tools & Settings > Scripts.
  2. Enter your MONTHLY_BUDGET and notification email.
  3. Schedule to run daily at 08:00 AM.

Frequently asked questions

Does this modify campaign budgets automatically?

By default, it only alerts via email to prevent unexpected changes. You can enable automatic budget adjustments if desired.

Need one of these adapted to your account?

We write Google Ads scripts, set up server-side GA4, and build the reporting that answers a specific question.