google ads monthly budget pacing script

Google Ads Monthly Budget Pacing Script

Google Ads scripts are powerful tools that allow advertisers to automate processes on this platform that would be otherwise tedious to do by hand. One such script is the Google Ads Monthly Budget Pacing Script, which helps advertisers stay on top of their monthly budget by pacing spending and sending alerts when necessary. 

In this article, we’ll take a closer look at how this free script works and how it can help you optimise your Google Ads campaign.

Let’s dive in. 

Google Ads Monthly Budget Alert Script

// Script that tracks monthly budget VS spend month to date.
// It sends email alerts when account has spent over 50% within first 10 days of the month or when account has reached 90% of the spend.
// It tracks emails in sent in google sheet
// It clears the tracking sheet on 1st of the month

var config = {
  budget: 1000, //add in monthly budgets
  emails: "[email protected], [email protected]", //email address for alerts
  emailTracker:
    "https://docs.google.com/spreadsheets/d/1fhL5ITvBzkZrHTz15ywhsLiv_-vr5LpcP4tz9Vz8XnU/edit", //sheet which gets updated with email info -> make a copy
  sheetName: "Email Tracker", //name of the sheet from the email tracker doc
};

function main() {
  var now = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
  var dateTrunc = new Date();
  var tenDays = new Date();
  dateTrunc.setDate(1);
  tenDays.setDate(10);
  var firstOfTheMonth = Utilities.formatDate(dateTrunc, "GMT", "yyyy-MM-dd");
  var tenthDay = Utilities.formatDate(tenDays, "GMT", "yyyy-MM-dd");
  var account = AdsApp.currentAccount().getName();
  var currency = AdsApp.currentAccount().getCurrencyCode();
  var accountId = AdsApp.currentAccount().getCustomerId();
  var query = `
      SELECT 
      campaign.name,
      campaign.id,
      metrics.cost_micros,
      campaign.status 
      FROM campaign 
      WHERE segments.date BETWEEN '${firstOfTheMonth}' AND '${now}'
      `;
  const report = AdsApp.report(query);
  const rows = report.rows();
  const campaignData = [];
  while (rows.hasNext()) {
    const row = rows.next();
    const campaign = row["campaign.name"];
    const status = row["campaign.status"];
    const campaignId = row["campaign.id"];
    const cost = row["metrics.cost_micros"] / 1000000;
    const campaignObj = {
      campaign: campaign,
      status: status,
      campaignId: campaignId,
      cost: cost,
    };
    campaignData.push(campaignObj);
  }

  //get the total cost MTD
  let costToDate = 0;
  campaignData.forEach(function (campaign) {
    costToDate += campaign.cost;
  });
  var percentOfBudgetSpent = costToDate / config.budget;

  // send emails when spend reaches 50% within first 10 days, when spend reaches 90% of budget and 100% budget. Track emails
  var spread = SpreadsheetApp.openByUrl(config.emailTracker);
  var sheet = spread.getSheetByName(config.sheetName);
  var sheetData = sheet.getDataRange().getValues();
  var email50sent = [];
  var email90sent = [];
  var email100sent = [];
  for (let j = 1; j < sheetData.length; j++) {
    if (sheetData[j][0] && sheetData[j][0] !== "") {
      email50sent.push(sheetData[j][0]);
    }
    if (sheetData[j][1] && sheetData[j][1] !== "") {
      email90sent.push(sheetData[j][1]);
    }
    if (sheetData[j][2] && sheetData[j][2] !== "") {
      email100sent.push(sheetData[j][2]);
    }
  }

  //check if alert has already been sent - if not then send an email
  if (
    now <= tenthDay &&
    percentOfBudgetSpent >= 0.5 &&
    percentOfBudgetSpent < 0.9 &&
    !email50sent.includes(accountId)
  ) {
    const subject = `${account} Budget Alert: Spend over 50% of allocated budget`;
    const emailBody = `Your Account ${account} has spent 50% or more of the allocated budget within the first 10 days of the month <p> Budget: ${currency} ${
      config.budget
    } and Spend Month To date: ${currency} ${costToDate.toFixed(1)}</p>`;
    MailApp.sendEmail({
      to: config.emails,
      subject: subject,
      htmlBody: emailBody,
    });
    var lastRow = email50sent.length;
    sheet.getRange(lastRow + 2, 1).setValue(accountId);
  } else if (
    percentOfBudgetSpent >= 0.9 &&
    percentOfBudgetSpent < 1 &&
    !email90sent.includes(accountId)
  ) {
    const subject = `${account} Budget Alert: You have spent 90% of the allocated budget`;
    const emailBody = `Your account ${account} has spent 90% or more of the allocated budget.<p> Budget: ${currency} ${
      config.budget
    } and Spend Month To date: ${currency} ${costToDate.toFixed(1)}</p>`;
    MailApp.sendEmail({
      to: config.emails,
      subject: subject,
      htmlBody: emailBody,
    });
    var lastRow = email90sent.length;
    sheet.getRange(lastRow + 2, 2).setValue(accountId);
  } else if (percentOfBudgetSpent >= 1 && !email100sent.includes(accountId)) {
    const subject = `${account} Budget Alert: You have spent the allocated budget`;
    const emailBody = `Your account ${account} spend has reached the allocated budget.<p> Budget: ${currency} ${
      config.budget
    } and Spend Month To date: ${currency} ${costToDate.toFixed(1)}</p>`;
    MailApp.sendEmail({
      to: config.emails,
      subject: subject,
      htmlBody: emailBody,
    });
    var lastRow = email100sent.length;
    sheet.getRange(lastRow + 2, 3).setValue(accountId);
  }

  var today = new Date().getDate();
  if (today === 1) {
    //clear the sheet from email data first of the month
    sheet.getRange(2, 1, sheet.getLastRow() + 1, 3).clearContent();
  }
}

Want to automate Google Ads with custom scripts?

If you liked this script or would like a personalized one, we’re here to help! Our team of developers with experience in PPC can create custom scripts to automate any aspect of your Google Ads accounts. Schedule a discovery call to discuss how we can assist you in implementing automation scripts effectively.

How to Use Scripts in Google Ads 

Adding and setting up scripts in Google Ads is a simple process that can yield significant benefits for your PPC campaign. 

To get started, navigate to the “Tools & Settings” tab and select “Scripts.” From here, you can create a new script or use an existing one. Once you’ve created or selected your script, you can customise it to suit your needs. 

Scripts can be used to automate a variety of tasks, such as bid management, ad scheduling and budget pacing. 

By using scripts to automate these tasks, you can save time and ensure that your PPC campaign is running at peak efficiency. Additionally, Google Ads scripts can help identify and resolve issues quickly, allowing you to stay on top of your campaign and make informed decisions about your advertising strategy.

What is the Google Ads Monthly Budget Pacing Script? 

The Google Ads Monthly Budget Pacing Script is a free, customisable tool that helps advertisers stay on track with their monthly advertising budget. 

The script is designed to track your campaign spend and compare it to the monthly budget you’ve set under the “config” section. This allows the script to monitor your spending and ensure that you’re not overspending or underspending throughout the month. 

What is Budget Pacing? 

Budget pacing is the process of tracking and optimising your PPC campaigns to control the rate at which your budget is spent. 

By pacing your budget, you can ensure that your campaigns are spending money efficiently and effectively throughout the month, rather than blowing through your budget early on and leaving you with limited ad spend for the rest of the month.

Effective budget pacing involves closely monitoring your campaign’s performance and adjusting your bids and targeting as needed to maximise your return on investment. This requires a deep understanding of your target audience, campaign goals, and available budget, all of which Google Ads budget monitoring helps keep under control. 

How Does the Google Ads Monthly Budget Pacing Script Work?

The Google Ads Monthly Budget Pacing Script works by tracking your monthly ad spend Month-to-Date (MTD) and comparing it to your pre-defined monthly budget. The script sends email notifications when your campaign spends over 50% of your monthly budget within the first 10 days and again when it reaches 90% and 100% of your monthly budget.

These email notifications include details about your campaign’s performance and spending, allowing you to quickly identify any issues and make informed decisions about your advertising strategy. 

You can act upon these notifications by adjusting your campaign’s targeting, bids, or other settings to optimise your spending and maximise your ROI. 

One of the key features of the Google Ads monthly budget pacer is its ability to send email alerts based on predefined thresholds. 

For example, if your campaign spends more than 50% of your monthly budget within the first 10 days of the month, the script will send you an email alerting you to the issue. This gives you time to adjust your spending and avoid going over your budget for the month.

Why Should You Use the Monthly Budget Alert Script?

As technology continues to evolve, automation is becoming increasingly necessary in order to keep up with the demand for faster, more efficient, and more cost-effective processes.

The Google Ads Monthly Budget Pacing Script is an essential tool for any marketer looking to take control of their ad spend and maximise the return on their advertising investment. 

By tracking your monthly ad spend Month-to-Date (MTD) and sending email notifications when you’ve reached pre-defined thresholds, this script helps you avoid overspending and stay within your budgetary constraints.

Using the monthly budget alert script also makes it easier to monitor multiple ad campaigns at once. Instead of manually checking each campaign for overdelivery, this script automates the process and sends email notifications when your spending has exceeded predefined limits. 

This allows you to quickly identify issues and take action to optimise your campaigns and stay within budget. 

The Google Ads Monthly Budget Alert Script is an invaluable tool for any marketer looking to stay on top of their ad spend and optimise their campaigns for maximum ROI. By automating tedious tasks and providing timely notifications about your spending, this script helps you achieve your advertising goals more efficiently and effectively.

Why Should You Use the Monthly Budget Alert Script?

When to Use the Google Ads Monthly Budget Pacing Script 

The Google Ads Monthly Budget Pacing Script is a versatile tool that can benefit a wide range of advertisers and agencies in various situations. 

Here are some examples of when it’s especially useful to use this script:

  • When managing multiple accounts. The Monthly Budget Pacing Script can help agencies track and optimise ad spend across multiple accounts, making it easier to stay on top of campaign performance and spending.
  • When working with tight budgets. If you have a limited budget, it’s essential to pace your ad spend effectively to maximise your ROI. The Monthly Budget Pacing Script can help you do this by alerting you when you reach spending thresholds and allowing you to adjust your campaigns accordingly.
  • During seasonal traffic influx. Seasonal traffic influx can cause unexpected spikes in ad spend, making it challenging to stay within the budget. The Monthly Budget Pacing Script can help you track and optimise your ad spend during these periods, ensuring that you’re getting the most out of your advertising budget.

How to Prevent Google Ads From Overspending Your Monthly Budget 

If you’re running a Google Ads campaign, overspending your monthly budget can be a frustrating and costly mistake. However, Google provides an alert system that can help you prevent overspending.

When you receive an alert indicating that your campaign has overspent, the first thing you should do is access your Google Ads account and review your campaign’s performance. Look for any areas where you may have set bids too high or targeted the wrong audience.

Once you’ve identified the issue, you can take action to stop your campaign from overspending. One option is to adjust your campaign settings and decrease your bids. You may also want to consider pausing the campaign altogether until you can fine-tune your budget and targeting.

Finally, make sure you keep a close eye on your campaign’s performance going forward to prevent overspending in the future. With these steps in mind, you can effectively manage your Google Ads campaigns and avoid costly mistakes.

Custom Automation Scripts by Acuto 

At Acuto, we believe that every agency deserves to unlock the full potential of their data. 

We create custom automation scripts for businesses so that they can spend less time on monotonous tasks and more time on the stuff that really matters.

We do this for just about any web app, including Google Ads, Google Sheets, Meta for Developers, Authoritas and more. By working closely with your team, we develop automation solutions that are tailored specifically to your business

Acuto can help you launch promotion campaigns with Google Ads scripts that save you time, labour and money. 

So, why work with us? 

We’re a team of developers and data engineers with extensive backgrounds in digital marketing and paid media. This enables us to create powerful automation scripts that get the job done, so you don’t have to. 

Key Takeaways 

To summarise, Google Ads Scripts do the hard work so that your team can optimise its PPC campaigns with unparalleled consistency, speed and authority. 

And lastly, to recap, here’s why we’re sure Google Ads scripts will improve your PPC campaigns:

  • Ensure that ad spend is spread evenly throughout the month
  • Prevent overspending on ad campaigns
  • Automatically adjust bids and budgets to optimise campaign performance
  • Save time and effort in manually monitoring and adjusting campaigns
  • Improve ROI by maximizing the use of available budget
  • Provide clients with more accurate and reliable budget projections and reports

If you encounter any issues while using the script, please contact us.

Recent Posts
google ads high CPC alert script

Google Ads High CPC Alert Script

Discover how Google Ads high CPC alert script can revolutionise the way marketing agencies optimise their campaigns.

pause google ads with low CTR script

Pause Google Ads with Low CTR Script

Use this free script to pause Google Ads with low CTR to help improve the efficiency of your campaign and avoid wasted ad spend.

Recent Posts