Advanced Budgets Script - User Guide

The script prevents you from going over your target budget

What does the Advanced Budgets script do?

This enhanced script checks if a keyword, ad, ad group or campaign is exceeding budget and pauses it automatically. It pauses the entity if the budget exceeds and then enables it again after the budget period has ended. The script enables you to:

  • Set budgets for campaigns, ad groups, keywords, or ad texts. 
  • Set budgets for monthly, weekly or daily periods. 
  • Pause items when their cost exceeds the maximum budget you specified. 
  • Re-enable paused items when a new budget period starts. 
  • Get notifications via email when changes are made or when an account exceeds a total cost for the period. 
  • Compatible with the following campaign and ad group types: search, display, shopping


This script can pause the following types of items:

  • Campaigns - Search campaigns, Display campaigns, Video campaigns and Shopping campaigns
  • Ad Groups - Search ad groups, Display ad groups, Video ad groups and Shopping ad groups
  • Keywords - Search keywords (alert and make changes automatically)
  • Ads - Expanded Text ad, Text ad (legacy format), Gmail Image ad, Gmail Single Promotion ad, Gmail Multi Product ad, HTML5 ad, Image ad, Mobile ad, Mobile image ad, Product ad, Responsive Display ad, Rich Media ad, Template ad, Video Ads. 

The script can also alert (but not make automatic changes) for the Keywords - Video keywords and Display keywords.

How does it work?

Choose the account you want to run the script in and go to the All Enhanced Scripts page. The script lets you set basic and advanced settings. You can have multiple settings for different budget periods and items. For example, one setting can be to pause keywords; another can be to pause account if the monthly budget exceeds.

Basic Settings

  1. Maximum Budget Amount:
    Enter the budget amount you want to pause the item for. The number in this field applies to each individual item. For example, if you set the budget amount to 10 and set the 'items to check' to keywords, the system will pause or report all keywords that exceed $10 individually. 

    This field doesn't support any characters other than a dot (.) to separate decimals. If the value you want to use is $10,5, you will need to write 10.5
  2. Items To Check:
    Select the items or entities in your AdWords account that you want to check the budget for. You can select - Account, Campaign, Ad Group, Ad Text or Keyword.
  3. Budget Period:
    This field mentions the time period the budget is valid for - daily, weekly, monthly. For the weekly option, you can choose the day the week starts on (Monday or Sunday).
  4. Pause Items:
    You can choose to pause entities or only generate a report. By default, this setting is set to 'No'.
  5. Email Addresses To Notify:
    The emails addresses that should be sent an email after the script runs.

Advanced Settings 

There are a few advanced setting options that let you choose which keywords, ads, ad groups and campaigns you would like to monitor. Advanced settings give you more control but are optional.

  • Check Only Items With This Label:
    Mention the AdWords label you want the script to check. The script will only check keywords, ads, ad groups or campaigns that have that label. For example, if you want to make sure non-brand keywords don't spend over a certain amount, you can label non-brand keywords and enter the label text in this field. 

    This is CaSe SeNsItIvE. The label must exist at the level of the entity whose costs you are checking. For example, if you are checking campaign level costs, the campaigns must have this label. When checking the account's cost, any label settings are ignored but you can achieve the same use case by switching to campaign budgets with a label. 
  • Campaign Name Contains:
    • Check only campaigns whose name includes this text. Case insensitive. 
    • This setting can be combined with "Check Only Items With This Label". When combined, both settings need to match (if one setting works, but the other one doesn't, the setting will fail)
    • You can only use one name (you can't separate different names with a comma).
  • Ad Group Name Contains:
    Check only ad groups whose name includes this text. Case sensitive. This setting can be combined with "Check Only Items With This Label".

    If item to check is either Account or Campaign, this setting will be override
  • Aggregate Costs:
    This allows you to consider the total cost of all items that matched the search criteria. When selected, the aggregate cost is compared to the budget. When not checked, each matched item's cost is individually compared to the budget.
  • Text Of Label To Add:
    In this field, you can mention the additional label you want to add to items that are paused by the script. The default is 'stopped_by_budget_script'.

    If you have more than one setting or your settings are targeting different items or time periods, we recommend you to always use different labels, especially if you are going to re-enable the items automatically. Otherwise, if you are using the same label, you might end up re-enabling the wrong item.
  • Reenable Items:
    If you would like the script to re-enable items that were paused by the script, you can change this field to 'yes'. To leave them paused, select 'no'.

How to install and run the enhanced script

After entering the details for each of the settings and clicking on 'Save Settings' button, you will get the option to 'Download' the script (at account or MCC level). 

We recommend you download the code in a .txt file. After downloading the code,  you can install the script in your AdWords account. 

For the script to re-enable the items it paused automatically, you need to schedule it to run at least every hour.

For detailed steps on how to install a script in AdWords read this article. This script can also be run at the MCC level (when you have several AdWords account in the same spreadsheet). This article explains how to install and run enhanced scripts at the MCC level. 

Recommendations and Tips

  1. Google AdWords has a 30-minute limit on scripts. If the account is very large and the script is checking keywords or ads, it'll time out before running through the whole account. A workaround to this is to create multiple settings and use a different label in each setting. 
  2. When you run the script the first time, run it with the 'Pause Items' field set to 'No' to see the results. If everything looks good, edit the setting in Optmyzr to automatically pause and resume items when the budget period ends.
  3. Schedule the script to run every hour in the AdWords account to make sure the paused items can be enabled when the budget period ends. It will also make sure the items can be paused as soon as they hit the budget.

Read more about tools for budget management in our blog post here.

Usage Tips and Examples

It can be tricky to set the Enhanced Script up correctly so here are a few tips and examples.

The script will evaluate entities in the account that match the combination of 'Items to Check' and filters like the following: 

  • 'Check Only Items With This Label' 
  • 'Campaign Name Includes'
  • 'Ad Group Name Includes'

You can combine filters for labels and names. For example, if you select 'Campaign', with label 'Search' and name includes 'BMM', the script will look ONLY at campaigns that have both the label 'Search' and whose name includes 'bmm' in any capitalization.

When you set 'Items to Check' to 'Account,' no filters for labels or names will be used. 

Items to Check
Label or Name filters
Pause when the cost of my entire account is too high
Pause when any campaign's cost exceeds the maximum cost
Pause any campaign with the label 'Test Label' when that campaign exceeds the maximum cost
Test Label
Pause all campaigns with the label 'Test Label' when the aggregate cost for all campaigns with this label exceeds the maximum cost. This also pauses campaigns whose individual cost is below the maximum cost.
Test Label

How to use the Spreadsheet - Sample

  • 1st row: Checks Monthly budget of 2000 at the account level
  • 2nd row: Checks an ad group label named "ad group test" for 200 monthly budget which is an aggregate budget
  • 3rd row: Checks an ad group label named "ad group test" for 400 monthly budget
  • 4th row checks an ad group "tools" for 200 monthly budget
  • 5th row: checks a campaign named "Optimization-New" for it's specified monthly budget
  • 6th row: checks another campaign in the account named "Brand" for its specified budget

Can’t find what you’re looking for?

Our award-winning customer care team is here for you.