boxoo
Menu
Guide · Audits & optimization

Google Ads scripts: how to add them, limits, and two scripts worth running

Google Ads scripts are free JavaScript that runs inside your account. The most useful ones watch the account and alert a person; the risky ones change things on every run with no undo.

Last checked against Google’s documentation on 5 October 2026.

What are Google Ads scripts?

Google Ads scripts are JavaScript programs that run inside a Google Ads account. Google’s scripts help page describes them as a way to make automated changes: change bids, pause ad groups, and add keywords with code instead of by hand. The same code can also read reports with Google Ads Query Language (GAQL), send an email, or write to a Google Sheet, so a lot of scripts never change anything at all. They watch the account and tell someone when a number looks wrong.

Scripts are free and run on Google’s servers on a schedule you set. That makes them one of the most useful tools in Google Ads for anyone who can read a little JavaScript. They are also easy to get wrong, because a script that changes the account does exactly what its code says, every time it runs, with nobody looking. This guide covers how to add one, the limits Google sets, two short scripts worth running, how scripts compare with automated rules, and how to keep one from doing damage.

How to add a script in Google Ads

Google’s steps, from the scripts help page:

  1. Click the Tools icon, open the Bulk actions drop-down, and click Scripts.
  2. Click the plus button to create a new script and give it a name in the “Script name” field.
  3. Paste or write the code in the editor.
  4. Click Authorize now, then Grant access. Google asks for authorization before a script can preview or run.
  5. Click Preview to see what the script would do, and read the logs.
  6. When the preview looks right, click Run script now, or schedule it.

To schedule, hover over the Frequency column on the Scripts page, click the pencil icon, and choose once, daily, weekly or monthly at a set hour. Each run is listed in Script history, with its log statements and a Changes view of what it did.

From code to a scheduled script
  1. WriteStart read-only: a report or an alert, not a change.
  2. AuthorizeGrant the script access to the account, and to email or Sheets if it uses them.
  3. PreviewRun it in preview and read the log and the list of changes it would make.
  4. SchedulePick a frequency and hour, then check Script history after the first runs.

Google Ads script limits to know

The figures below come from Google’s scripts limits page. The execution limit is the one people hit first: a script that loops over every keyword in a large account and makes one call per keyword can time out before it finishes.

30 minRun time per scriptUp to 60 minutes for manager account scripts using executeInParallel with a callback.
50,000Results per iteratorThe default cap on entities an iterator returns.
50Accounts in parallelFor a manager account script using executeInParallel.
250Authorized scriptsPer account for scripts using OAuth2.

Logs are cut off at 100 KB, so log a summary rather than every row. Scripts also inherit the daily quotas of the Google Apps Script services they call, such as email and URL fetch. Google’s limits page also notes that the standard campaign selector excludes Video and Shopping campaigns, which have their own selectors. Read the data with a GAQL query through AdsApp.search() where you can: one query is faster than thousands of individual calls.

Script 1: a daily budget pacing alert

This script changes nothing. It reads today’s cost and the daily budget of every enabled campaign and emails you the ones that have already spent more than a threshold you choose. Schedule it daily at an hour when an alert is still useful, for example early afternoon in the account’s time zone (GAQL date ranges such as TODAY are evaluated in the account’s time zone, per Google’s date ranges reference).

// Budget pacing alert: read-only. Emails campaigns that have
// already spent more than THRESHOLD of their daily budget today.
const EMAIL = 'you@example.com';
const THRESHOLD = 0.8; // 80% of the daily budget

function main() {
  const rows = AdsApp.search(
    'SELECT campaign.name, campaign_budget.amount_micros, ' +
    'metrics.cost_micros, customer.currency_code ' +
    'FROM campaign ' +
    "WHERE campaign.status = 'ENABLED' AND segments.date DURING TODAY");

  const lines = [];
  while (rows.hasNext()) {
    const row = rows.next();
    const budget = Number(row.campaignBudget.amountMicros || 0) / 1e6;
    const cost = Number(row.metrics.costMicros || 0) / 1e6;
    if (budget > 0 && cost / budget >= THRESHOLD) {
      lines.push(row.campaign.name + ': ' + cost.toFixed(2) + ' of ' +
        budget.toFixed(2) + ' ' + row.customer.currencyCode);
    }
  }
  Logger.log(lines.length + ' campaign(s) over threshold');
  if (lines.length && !AdsApp.getExecutionInfo().isPreview()) {
    MailApp.sendEmail(EMAIL, 'Budget pacing alert', lines.join('\n'));
  }
}

Three details make it work:

  • Micros. GAQL returns money as cost_micros and amount_micros, in millionths of the account currency, so divide by 1,000,000. The script prints the account’s own currency code rather than assuming one.
  • Field names. With AdsApp.search(), fields you select in snake_case come back in lowerCamelCase: campaign_budget.amount_micros is read as row.campaignBudget.amountMicros, as Google’s reports guide shows.
  • Preview. AdsApp.getExecutionInfo().isPreview() stops the email while you preview, the pattern Google uses in its execution info example.

One caution on reading the result: Google can spend more than the average daily budget on a given day and balance it over the month, so a campaign over 100% at lunchtime is not automatically a fault. Our guide to Google Ads spending more than the daily budget explains when it is.

Script 2: keywords spending with no conversions

The second script lists enabled keywords that spent more than a set amount in the last 30 days with zero conversions. It also changes nothing; it gives you a list to review. Set MIN_COST to something meaningful for the account, such as your target cost per conversion. The amount below is illustrative.

// Zero-conversion keywords, last 30 days: read-only report.
const MIN_COST = 100; // illustrative: in the account's currency

function main() {
  const rows = AdsApp.search(
    'SELECT campaign.name, ad_group.name, ' +
    'ad_group_criterion.keyword.text, ' +
    'ad_group_criterion.keyword.match_type, ' +
    'metrics.clicks, metrics.cost_micros ' +
    'FROM keyword_view ' +
    "WHERE ad_group_criterion.status = 'ENABLED' " +
    'AND metrics.conversions = 0 ' +
    'AND metrics.cost_micros > ' + MIN_COST * 1e6 + ' ' +
    'AND segments.date DURING LAST_30_DAYS ' +
    'ORDER BY metrics.cost_micros DESC');

  while (rows.hasNext()) {
    const row = rows.next();
    Logger.log([
      row.campaign.name,
      row.adGroup.name,
      row.adGroupCriterion.keyword.text,
      row.adGroupCriterion.keyword.matchType,
      row.metrics.clicks,
      (Number(row.metrics.costMicros) / 1e6).toFixed(2),
    ].join(' | '));
  }
}

Before pausing anything on this list, check three things the script can’t: whether the keyword is new, whether conversions usually arrive days after the click, and whether the search terms behind it are relevant. A keyword with irrelevant search terms often needs negative keywords rather than a pause; see how to find negative keywords.

Other useful Google Ads scripts

The best Google Ads scripts are usually the boring ones: they watch for something that breaks quietly and tell a person. Ideas that fit the limits above and need nothing beyond GAQL and email:

  • Conversion silence alert. Email when yesterday’s conversions are zero for a campaign that normally records them. A broken tag shows up here first; see conversions dropped to zero.
  • Search terms export. Write last week’s search terms with cost and conversions to a Google Sheet for review.
  • Account anomaly report. Compare yesterday’s cost, clicks and conversions with the same weekday over the past few weeks and flag large moves.
  • Disapproved ads report. List ads whose policy status isn’t approved so someone fixes them the same day.
  • Landing page check. Fetch each final URL with UrlFetchApp and report the ones that don’t return a success status, staying inside the URL fetch quota.

Scripts that change things, such as bid adjusters, budget shifters, or scripts that pause keywords, are where the risk sits. Start them in preview, and give them hard limits.

Scripts vs automated rules vs review tools

Google Ads automated rules are the no-code option. Google’s automated rules page says they make automatic changes based on conditions you choose, such as changing ad status, budgets and bids or sending an email, and you create them under Rules in the Tools menu or from a selection of items. Google’s tips for automated rules recommend minimum and maximum limits for bids and budgets, a long enough timeframe, previewing before saving, and starting with a one-time rule; rules typically run within two hours after their conditions are met.

Automated rulesScriptsReview tools (such as Boxoo)
SetupPoint and clickJavaScriptConnect the account
LogicOne condition set, one actionAnything the API and code can expressFixed set of checks run by the tool
ChangesApply automatically when conditions matchApply automatically when the code runsProposed; applied only when you approve
UndoBulk actions undo, onceNot on Google’s bulk actions undo listDepends on the tool; Boxoo keeps an undo for most applied fixes
CostFreeFree, plus your timeVaries by tool

Use a rule when the logic fits one sentence (“if a campaign spends this much today, email me”). Use a script when you need data a rule can’t see, a custom output, or logic across many items. Use a review tool when you want the account checked broadly every day and a person to decide on each change. They combine well: plenty of accounts keep a couple of alert scripts running alongside everything else.

The risks: scripts that change things on their own

A script that changes bids, budgets or statuses does it without review on every run. The common ways it goes wrong:

  • No way back. Google’s bulk actions undo covers bulk edits, copy and paste, automated rules and bulk uploads. Scripts aren’t on that list. If the script doesn’t record the old values, reversing a bad run means rebuilding them from change history.
  • Compounding changes. A script that raises bids 10% whenever a keyword converts cheaply will keep raising them every run until something else stops it.
  • Bad data in, bad changes out. If conversion tracking breaks, a script that pauses “keywords with no conversions” pauses everything.
  • Fighting Smart Bidding. Scripts written for manual bidding can change settings that a Smart Bidding strategy manages, or change targets often enough to keep it learning.
  • Forgotten scripts. A script written for last year’s structure still runs on this year’s campaigns. List what is scheduled on the Scripts page every quarter.
  • Copied code. A script from the internet runs with the access you authorize. Read it before you authorize it, especially anything that fetches URLs or sends data out of the account.

Before you schedule a script

  1. Read the whole script, and know which entities it reads and which it changes.
  2. Preview it, read the log, and check the list of changes.
  3. Prefer alerts and reports; let people make the changes until the script has earned trust.
  4. For changing scripts, log old values, cap the size of each change, and keep a dry-run switch.
  5. Check it stays inside 30 minutes on your largest account, using GAQL rather than per-item calls.
  6. Schedule it, then read Script history after the first few runs.

If you’d rather not maintain code, Boxoo covers the same ground differently. The budgets and bidding agent checks spend against budget and targets, and the search terms and keywords agent finds keywords and searches that spend without converting. Each finding arrives as a case with the evidence and a prepared fix, such as pausing a keyword, adding a negative keyword or changing a budget. Nothing changes until you press Apply, and applied changes keep an undo; match type changes come to you as exact steps. Our optimization routine shows where scripts and reviews fit in a weekly rhythm.

Run a free Google Ads audit to see what a daily review finds in your account.

Questions

What are Google Ads scripts?

JavaScript code that runs inside your Google Ads account. Google says scripts let you make automated changes, such as changing bids, pausing ad groups, and adding keywords, and they can also read reports and send emails. You add them under Tools, Bulk actions, Scripts.

Are Google Ads scripts free?

Yes. Scripts are part of Google Ads and cost nothing to run. The cost is time: someone has to write or adapt the code, check it in preview, and maintain it when the account or the API changes.

How long can a Google Ads script run?

Up to 30 minutes per run. Manager account scripts that process accounts in parallel with executeInParallel and a callback can run up to 60 minutes. Scripts can be scheduled once, daily, weekly or monthly at a chosen hour.

What is the difference between Google Ads scripts and automated rules?

Automated rules are point-and-click: pick items, a condition, and an action such as changing a budget, a bid or a status, and run it once or on a schedule. Scripts are code, so they can combine data, write to a spreadsheet, send a custom email, or apply logic a rule can’t express. Rules are covered by the bulk actions undo; scripts are not.

Can I undo changes made by a Google Ads script?

Google’s bulk action undo covers bulk edits, copy and paste, automated rules and bulk uploads; scripts are not on that list. Have the script write the old value of everything it changes to a log or sheet before changing it, so you can set it back by hand.

Keep reading

Get the checks a script would run, without maintaining the script.

Boxoo’s agents review budgets, search terms, keywords and tracking in your Google Ads account every day and file each finding as a case with the evidence. Nothing changes until you approve a fix, and applied changes keep an undo.