Back to Blog

A Google Ads Budget Pacing Script For Controlling Multiple Budgets

February 25, 2021

By Jessica Budde
No Comments

Reality check: budget management in Google Ads is not easy. As every Google advertiser knows, from novice to seasoned professional, setting a daily budget for a campaign is not enough to keep your spending in check.

Why?

Because we live in a world where Google can spend up to 2x your campaign’s daily budget.

When you’ve got a tight budget to stick to (or even if you don’t!), Google’s frivolousness with your daily limits can be extremely problematic.

As Google puts it:

While the cost of your campaign can be up to 2 times your average daily budget on any given day, you won’t be charged more than the monthly charging limit that Google Ads uses to prevent you from accidentally getting overcharged. This means that as long as your budget is consistent for an entire month, you won’t be charged more than your average daily budget multiplied by the average number of days in a month, which is 30.4 (365 days in a year ÷ 12 months).

OK… but what if you make a change to your budget mid-month?

Then you won’t exceed your new daily budget multiplied by the rest of the days in the month. Gulp.

Nothing a little math can’t solve, but if you’ve made changes to more than one campaign or are managing multiple budgets within an account, this gets messy fast. And now you’re sitting there doing your best with a calculator, checking in on spends multiple times a day – burning time that would be much better spent digging into performance data and optimizing your campaign.

No one wants that. Not you, not your boss, not your clients. Maybe Google, but that’s another can of worms entirely.

The Problem

If you’ve been following our blog for a while (thanks!) you might be saying to yourself “Hey, this sounds familiar. Didn’t you already share an amazing solution for keeping your Google Ads account from overspending?”

And the answer would be yes, we did. But the script we shared in our previous post only works if you have a single, account-level budget. And as we recently found out with a client of our own, sometimes that doesn’t cut it.

In our situation, we needed to manage spends across remarketing campaigns with one budget, separate from our prospecting efforts. Campaign-level daily budgets got us halfway there, but when it came to using our previous daily budget management script, we faced the dilemma of either having all campaigns at the mercy of the lower budget and turning off too soon or excluding them from the script and running all the time, potentially overspending.

Either way, not ideal.

The Solution

So, we once again turned to our development team for a better solution. They modified our original script to allow us to set daily spending limits for different groups of campaigns. One script, multiple budgets.

For example, rather than set one limit of $1,000/day, account-wide, with the new script, you can pause all campaigns in Group A once their spend hits a total of $300, while Group B remains unaffected until those campaigns hit their own, separate daily limit of $700.

Sounds great, right? It is. Though there are some limitations, which will reveal themselves below.

How It Works

If you’re already using our single-budget script, the implementation of our multiple-budget script should be very familiar to you – just a few modifications are needed to your existing setup. If you’re new, setup is easy, but there’s more to our budget management approach than just the script. We also use labels and automated rules to keep things running smoothly. So read on!

The free script we’re providing in this post will check the total spend of each campaign group, every hour. If the group of campaigns has spent more than the maximum amount you’ve set, the script will pause all active campaigns in that group (unless you specify that certain campaigns remain active, we’ll cover that in a second).

Now you’re probably thinking that you will have to check all of your accounts every day to see which campaigns were paused the day before and re-enable them, right? 

Good news – you don’t! Using an automated rule, Google Ads can do that for us. 

The automated rule will run at midnight every day to check if any of the campaigns labeled “Active” are paused. If they are, it will re-enable them. 

We’ll walk you through the entire setup.

But first, quick check. The following setup is intended for use in accounts with multiple budgets. If you are looking for a script to curb overspending with a single limit at the account-wide level, please check out our post here.

Step 1: Leveraging Labels

The most important thing to note when using this Google Ads budget-management strategy is that it’s entirely dependent on consistent and up-to-date campaign labels. 

To utilize the script, you’ll have to create the following labels in your account: 

Labels required for pausing/re-enabling:

  • “Active” label for all enabled campaigns. This is vital for the automated rule to work properly. 
  • “nopause” label for any active campaigns that you do not want the script to make changes to. You need to create this label even if you have no plans to use it. Without it present in the account, the script may appear to run, but will not make any changes.

For example, maybe you always want your ads to show up for branded searches. In this case, you would label every campaign with branded keywords “nopause”.

As you’re creating new campaigns or pausing others, it’s vital that you keep labels accurate and up-to-date. If you pause a campaign manually and forget to remove the “Active” label, the automated rule will re-enable that campaign when it runs. If you forget to add the “Active” label to a new campaign and it’s paused by the script, it will not be re-enabled the next day.

Labels required for assigning spend limits:

  • “Budget name A” label for campaigns in your first group.
  • “Budget name B” label for your next group of campaigns that share a daily spend limit.

Create at least two groups of campaigns (and their labels), up to as many as you need. These labels can be any name that makes sense to you, but make sure the label you create exactly mirrors the label’s name as you have it written in the script (including case sensitivity).

Step 2: Setting Up the Script

The rest of this process will all take place in the “Bulk Rules” section of Google Ads, where you can set up and manage scripts and automated rules.

To enable this script in your account, follow these steps:

1.Under the “Tools & Settings” menu in Google Ads, select “Scripts” under the “Bulk Actions” category. 

2. Click the blue plus sign on the top left side of your screen to add a new script. 

3. Enter a name for your script in the top left corner of the window. We named ours “Pause Campaigns When Max Daily Spend is Reached – Multiple Budgets”.

4. Copy and paste this free script into the editor area:

/**
 *  "name": "Evergreen Campaigns", //your campaign name just for identifying
 *  "label": "Evergreen", //the ads label you applied for this campaign
 *  "max_spend": 500, //the max total spend for this ad label group, including video
 */
var CAMPAIGN_CONFIG = {
    "campaigns":[
        {
            "name": "Evergreen Campaigns",
            "label": "Evergreen",
            "max_spend": 500
        },
        {
            "name": "Summer 2021 Campaigns",
            "label": "Summer21",
            "max_spend": 500
        },
    ]
}
var TODAYS_SPEND = 0;
function main() {  
    CAMPAIGN_CONFIG.campaigns.forEach(function (myCampaign){
        TODAYS_SPEND = 0; //reset for each campaign
        processTodaysSpend(myCampaign);
        processCampaignPause(myCampaign);
    });
}
function processTodaysSpend(myCampaign) {
    //Get Ad Spend
    TODAYS_SPEND += getTodaysCosts(AdsApp.campaigns().withCondition("LabelNames CONTAINS_ANY ['"+myCampaign.label+"']").forDateRange('TODAY').get());
    //Get Video Spend
    TODAYS_SPEND += getTodaysCosts(AdsApp.videoCampaigns().withCondition("LabelNames CONTAINS_ANY ['"+myCampaign.label+"']").forDateRange('TODAY').get());
}
function processCampaignPause(myCampaign) {
    if (TODAYS_SPEND > myCampaign.max_spend) {
        var adsSelector = AdsApp.campaigns()
        .withCondition("LabelNames CONTAINS_ANY ['"+myCampaign.label+"']")
        .withCondition("LabelNames CONTAINS_NONE ['nopause']")
        .get();
        var videoSelector = AdsApp.videoCampaigns()
        .withCondition("LabelNames CONTAINS_ANY ['"+myCampaign.label+"']")
        .withCondition("LabelNames CONTAINS_NONE ['nopause']")
        .get();
        Logger.log("Pausing "+ myCampaign.name)
        //Pause Ads
        pauseCampaigns(adsSelector);
        //Pause Videos
        pauseCampaigns(videoSelector);
    }
}
function getTodaysCosts(selector) {
    var totals = 0;
    while(selector.hasNext()) {
        var campaign = selector.next();
        var stats = campaign.getStatsFor("TODAY");
        totals += stats.getCost();
    }
      return totals;
}
function pauseCampaigns(selector) {
    while(selector.hasNext()) {
        var campaign = selector.next();
        campaign.pause();
    } 
}

5. Set your names (reference only, great for adding context around short labels) and labels for each budget group

You will set this in lines 9 and 10 for the first budget, 14 and 15 for the second.

6. Set your daily maximum budget for each campaign group

You will set this in lines 11 and 16 for the first two budgets.

If you have more than two budgets to manage, duplicate lines 13-17. Our script has a pre-filled limit of $500 for each.

Example of name, label, and max spend entry

7. On the bottom right-hand corner of your screen, hit “Save”, and then “Run”. You’ll see a pop-up asking you whether or not you want to preview the script before running. Select “Run Without Preview”.

8. You’ll then see a yellow banner at the bottom of the Google Ads window asking you to authorize the script to run, select “Authorize” and follow the steps for authorization.     

9. Select “Scripts” on the left side of your screen to return to the general scripts page. 

10. From this page, you’ll see all of the scripts in the account and can specify how often your scripts will run. Under the “frequency” column for the script you just created, select “hourly”.*

Setting frequency to hourly on scripts page

*This script only runs every hour, so it’s still possible to slightly overspend the maximum spend that you set. If your daily spend limit of $500 is hit at 3:15 but the script does not run until 4:00, your ads will continue to run for that 45 minutes.

 Step 3: Setting Up the Automated Rule

Now it’s time to create the automated rule that re-enables all “Active” campaigns the following day.

1.  From the bulk actions page, select “Rules.”

2. Press the blue plus sign on the top left side of your screen to add a new rule, then select “campaign” rules.

3. Choose “Enable Campaigns” as your type of rule.

4. Apply to all “enabled or paused campaigns.”

5. Add the condition “Label contains all ‘Active’”

6. Set the frequency as daily at 12:00 A.M. using data from the same day. 

7. Now, choose whether or not you want an email notification when the rule runs (we recommend you do so that you can stay on top of potential overspending). 

8. Finally, name your rule. We went with “Daily Re-Enable.”

setting up automated rule on rules page

And that’s it! For those of you juggling multiple budget limits within your Google Ads account, you’re well on your way to fewer headaches, less math, and less worry.


This script came to be out of our need to manage remarketing and prospecting budgets separately, but it’s also a great solution for anyone that needs to keep costs in check across different initiatives, adjust some campaigns for seasonality, make sure different levels of spend are allocated properly toward various conversion actions… you get the idea, anyone with multiple budgets to manage within the same Google Ads account. If that’s you, and this script helped you pace spending better, or if you modified it further for a different use case, let us know in the comments!

Jessica Budde

Jessica Budde

Jessica is a Digital Marketer at Cypress North and co-host of the weekly digital marketing news podcast, Marketing O'Clock. She loves working with people, has a passion for details, and tends to nerd out over all things tracking. She holds a Master’s in television, radio, and film from Syracuse University with a Bachelor's in communication studies from Niagara University.

See Jessica's Most Recent Posts

Share this post

Leave a Reply

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

Search our blog

Start A Project

Categories

What's next?

Well...you might like one of these

Article

How to Target Top Content With Google...

Google Ads may be the most multi-faceted Ad Platform...

Read article

Article

How To See Audience Performace Across...

Google Ads makes it really easy to see performance at the...

Read article

Article

Is Google Ads Close Variant Matching...

Looking at search terms that we've seen here recently,...

Read article