Stop Google Ads Budget Overspend with This Simple Script

I had the opportunity to present recently at a monthly meeting of the Utah Digital Marketing Collective (Utah DMC, formerly SLCSEM). I spoke about a handful of scripts that advertisers could put to use immediately. One of those scripts prevents Google Ads from spending 2X your daily budget on any given day. Several people were interested in the script which leads me to believe this is a more common issue than I thought. So I’m sharing it here to get it out there more.

Stop Daily Campaign Overspending

Back in October last year we got this “treat” of a tweet from AdWords:

The platform already “allowed” itself to overspend daily budgets by up to 20%. It has been a thorn we’ve all just accepted, but this was 5 times worse and foisted on all advertisers unilaterally. They did include this line to soften the blow, though – “Keep in mind, you won’t be charged more than your monthly charging limit: the average number of days in a month (30.4) multiplied by your average daily budget.”

Didn’t help much.

So let me help you stop this from happening in your account with a simple AdWords script. First, copy the following code:

function main() {

var allowedOverdeliveryPercentage = 0.2; // set percentage as decimal, i.e. 20% should be set as 0.2
var labelName = "Paused for Overdelivery";

AdWordsApp.createLabel(labelName, "automatic label needed to reenable campaigns");

var campaigns = AdWordsApp.campaigns()
.withCondition("Status = ENABLED")
.withCondition("Cost > 0")

var campaignIterator = campaigns.get();

while (campaignIterator.hasNext()) {
var campaign =;
var campaignName = campaign.getName();
var budgetAmount = campaign.getBudget().getAmount();
var costToday = campaign.getStatsFor("TODAY").getCost();

if(costToday > budgetAmount * (1 + allowedOverdeliveryPercentage)) {
Logger.log(campaignName + " has spent " + costToday + " which is more than allowed.");
} else {
Logger.log(campaignName + " has spent " + costToday + " and can continue to run.");


Then take these steps:

  • In Google Ads, click the Tools icon in the upper right corner (it’s a wrench)
  • Then click on Scripts in the Bulk Actions section
  • On the next page click the blue circle with a + sign in it (this is how you add a new script)
  • On this screen you will name your script. I recommend a very descriptive name like [account] – [what script does/campaigns it affects] – [how often it runs]
  • Copy/paste the code into the main section
  • Click Save (I’m just a little neurotic about losing work)
  • Authorize the script by clicking “Authorize” in the yellow bar. You’ll then have to double opt-in that you’re okay with running the script
  • Set the allowable over-delivery percentage in line 3 (instructions included in script text). You can use 0.2 to go back to pre-October 2017 behavior or choose your own level.
  • Click Save (yes, do it again)
  • Click Preview & then check the Changes & Logs tabs to make sure it will run successfully.
  • If everything checks out then click Run and you’re done

This script will run every hour and pause any campaign that goes over the threshold you set. It then reactivates it at midnight so it’s good for the next day.

If you liked this post, you may be interested in these posts:

How do you manage your AdWords budgets? We’d love to hear your tips in the comments!

Comments (16)

  1. Hey, I tried this script with no manual changes but I’m getting error “Illegal character. (line 4)”. What do you suggest?

  2. If you receive an “illegal character. (line 4)” error message, try changing all double quotes (“) to single quotes (‘) on lines 4, 6, 9, 10, 11, 19, 22, and 26.

  3. Hi Robert, I got the script running, but what should I see in the log to know that its running successfully?

  4. The cause of the error is the double quotes in this posts “ which is not your standard double quotes. Change them to either normal double quotes or single double quotes.

  5. I’m very hopeful this script will be our solution. But I see an error message after each time it runs. The status will show “Finished with errors Completed in 2 (or other number) seconds”. The error message is in the Status field and reads “You’re already using this label name”. Do you know how to remedy this error message? Thanks.

  6. Based on your comment it seems like you potentially are already using the label for something else. You can change the label the script is using to reenable the campaigns. It’s the 3rd line. Just take out “Paused for Overdelivery” and give it a name that is not being used. That should clear it up.

  7. Thanks for the reply, it runs fine with no errors the first time, but each time it runs after, it then shows the 1 error stating “You’re already using this label name.” It does this even if I change the label. The first time I change the label it will show no errors. But each time after, that error message will appear. It still appears to work despite the error message.

    However, it is also not restarting the next day. I’m thinking that problem might be because I don’t have the ads scheduled to run at midnight.

    Thanks for your help!

  8. Rellay great. Th aks for helping me to minimize my manul work hrs. It’s very efficient.

    Thank a lot.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.