Pause Overspending Campaigns Google Ads Script

Google Ads Script to Pause Overspending Campaigns

Next up in our series of quick scripts we’re creating for free following requests is a simple script to pause your campaigns if they spend over a certain threshold of your budget, and then re-enable them the next day.

A few years ago Google changed the over-delivery threshold from 20% to 100%, and while this is fine for most advertisers there are often cases where this isn’t ideal. A mid-sized agency based in Denver asked us to build this for them, and since it was only a few lines of code – here it is an hour later!

The script only has two parameters. The over- delivery threshold, which is the most additional budget that can be spent – 20% means that a campaign with a budget of $100 will be paused once it’s spent $120. The second parameter is only needed if running the script in an MCC – and indicates the accounts within that MCC on which the script should run.

The script must be set up to run hourly in order to function properly. Any less than that, and it either won’t pause overspending campaigns, or it won’t re-enable them after they’ve been paused.

On that note, it’s also important to remember that the script can only run once an hour, so it’s not guaranteed to pause campaigns just as they high 20% – in fact, it’s likely they’ll be paused slightly after this threshold is reached.

The script knows which campaigns to enable the next morning based on labels, so please don’t remove the ‘Paused – Budget Overdelivery’ label that the script will apply – it’ll remove the label on its own once the new day starts and its time to re-enable the campaign.

As always, and as with any script, ensure you understand what it’s doing before applying it, and preview it before running to ensure the changes its making are as you’d expect.

/*

    _   ___ _   _ _____ ___   _     
   /_\ / __| | | |_   _/ _ \ (_)___ 
  / _ \ (__| |_| | | || (_) || / _ \
 /_/ \_\___|\___/  |_| \___(_)_\___/
                                    

*/

config = {
  overdeliveryThreshold: '20%', // The maximum over budget the campaign can go before it gets paused
  accounts: ['494-823-7580'] // The accounts in this MCC the script will run on, ignore if using on a single account
}

function main() {  
  try {
    AdsManagerApp.accounts().withIds(config.accounts).executeInParallel('pauseOverspendingCampaigns');
  } catch(e) {
    pauseOverspendingCampaigns();
  }
}

function pauseOverspendingCampaigns() {
  
  var labelName = 'Paused - Budget Overdelivery';
  
  // Unpause any campaigns that were previously paused
  var date = Utilities.formatDate(new Date(), AdsApp.currentAccount().getTimeZone(), 'MMMM dd, yyyy HH:mm:ss Z');
  var hour = parseFloat(date.split(' ')[3].substring(0, 2));
  if (hour < 3) {
    var campaigns = AdsApp.campaigns().withCondition('LabelNames CONTAINS_ANY ["' + labelName +'"]').get();
    while (campaigns.hasNext()) {
      var campaign = campaigns.next();
      campaign.removeLabel(labelName);
      campaign.enable();
    }
  }

  // If the label already doesn't exist, create it
  if (AdsApp.labels().withCondition('Name = "' + labelName + '"').get().totalNumEntities() === 0) AdsApp.createLabel(labelName);
  
  // Iterate through campaigns and check for any that are overspending
  var campaigns = AdsApp.campaigns().forDateRange('TODAY').withCondition('Cost > 0 AND Status = ENABLED').get();
  while (campaigns.hasNext()) {
    var campaign = campaigns.next();
    var budget = campaign.getBudget().getAmount();
    var cost = campaign.getStatsFor('TODAY').getCost();
    var threshold = (parseFloat(config.overdeliveryThreshold.replace('%', '')) / 100) + 1;
    var maxSpend = budget * threshold;
    if (cost > maxSpend) {
      campaign.applyLabel(labelName);
      campaign.pause();
    }
  }
}

How to Use Scripts in Google Ads

Google Ads scripts are JavaScript codes that can be used to save time and effectively manage your campaigns. 

To run a script, all you have to do is insert the JavaScript code into the script editor, save it, and run it. With Google Ads scripts, you can automate tasks such as pausing campaigns, reactive bidding, ad customization and adding keywords.

Here are step by step instructions:

  1. Sign in to your Google Ads account
  2. Choose the Tools and Settings drop-down menu from the toolbar.

    Google Ads Script to Pause Overspending Campaigns

  3. Select Scripts from the list of Bulk Actions.

    Google Ads Script to Pause Overspending Campaigns

  4. To create a new script, click the blue + icon

    Google Ads Script to Pause Overspending Campaigns

  5. Choose one of the following options: New script or Start from a template
  6. In the name bar, type a name for your script.
  7. Copy and paste your script code into the editor.
  8. To enable the script to run on your account, click Authorize.
  9. You can now Save & Preview your script.
  10. Check the logs on your preview to ensure the script will run as expected
  11.  Click Run to execute the script when you’re ready.

How Does the Google Ads Budget Work?

The Google Ads platform is a type of pay-per-click (PPC) advertising, meaning you only pay for each click that your ad receives. When setting up in Google Ads, you need to provide a daily budget for your campaigns.

Essentially, this is an average daily budget based on the amount you’re willing to spend per day. If a client has several different campaigns with a shared goal, you can create a shared budget to track them all effectively at once. 

You also have to set bidding options, including the maximum cost-per-click you’re willing to pay. Generally speaking, the higher your bid, the more traffic your ad will get and the higher your ROI will be.

However, the Google Ads daily budget is a guideline, not a limit. It can fluctuate from day to day, meaning you can end up spending above or below your daily campaign budget. 

Why Does Google Ads Overspend on Campaigns? 

As previously mentioned, the Google Ads budget is a guideline, not a limit. In fact, when your Google Ads daily budget is overspent, this is known as “over-delivery”. 

Spending fluctuations are often influenced by how well your ad is performing, such as its click-through rate and conversions. Depending on the amount of traffic your ad receives, Google Ads can spend up to twice as much as your daily budget

This means that Google Ads’ bidding algorithms may adjust spending in order to improve clicks and conversions during periods of high conversion rates or peak search volumes. 

Overspending costs can accumulate quite quickly, creating a major problem for agencies with limited budgets or several clients running multiple campaigns simultaneously.

How Much Does Google Ads Allow to Be Overspent? 

Google Ads overspending can be much higher than expected, but fortunately there’s a limit to this. Basically, Google Ads multiplies your average daily budget by 30.4 days (average days per month), so you’ll never be charged more than that in any given month. 

For example, if you set your budget at £10 a day, you will never pay more than £304 for that month overall. There’s also a daily upper limit, which is basically two times your average daily budget. 

Even so, there are several ways you can avoid Google Ads overspending and reduce unnecessary costs.

#1. Use Google Ads Automated Rules and Scripts

One of the most effective ways to stop Google Ads from overspending are Google Ad scripts. These can constantly manage all your campaigns simultaneously and alert you to any underperforming ads.

Moreover, you can have Hard Stop Scripts pause Google Ads campaigns automatically when you reach your maximum daily budget.

#2. Use Negative Keywords

Adding negative keywords is a full-proof strategy to boost your Google ad CTR and increase conversions, thereby reducing Google Ads overspending. Basically, negative keywords will prevent your ads from appearing in searches that are irrelevant to your intended audience, improving ad performance and reducing spending on ineffective campaigns. 

#3. Monitor Ad Campaigns Frequently

Monitoring ad campaign performance data, such as conversion rates, clicks and impressions, will help you identify which ads are performing well and which are underperforming. You can then pause any underperforming ads or decrease your bids, thereby reducing the risk of overspending and boosting your quality score. 

Again, bespoke software like custom Google Ad scripts can take care of this for you. 

#4. Make Bid Adjustments Accordingly

Bid Adjustments is an excellent built-in feature in Google Ads that you can use to improve ad performance and stop Google overspending. With bid adjustments, you can adapt your bids to specific segments of your target audience to ensure your ads reach your target audience and boost conversions. 

You can also avoid overspending by setting a lower daily budget. For example, if your budget is £60 a day, you could set your bid at £30.

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.

Key Takeaways

By now, you should feel more comfortable using scripts in Google ads and know how to avoid overspending. 

But let’s go over some of the main points: 

  • Google Ads Budget is the average daily amount you are willing to spend. You can also create a shared budget across different campaigns for a single client.
  • Google Ads overspend if your campaigns are not bringing in the intended amount of conversions. This can become quite costly if you have several different campaigns at once. 
  • Overspending per day can be double your daily budget, however it will never exceed that, nor your overall monthly budget. 
  • There are several ways you can avoid overspend, which includes using google ad scripts, monitoring campaigns regularly, using negative keywords in your campaigns and adjusting bids accordingly. 
  • Acuto develops custom scripts tailored to your agency’s needs to prevent unnecessary costs. 
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