Est.

Google Ads Scripts for Custom Automation in B2B Accounts

Scripts automate routine account tasks B2B managers can't monitor manually.

Senior Writer · · 10 min read
Cover illustration for “Google Ads Scripts for Custom Automation in B2B Accounts”
AI in Paid Search · October 4, 2026 · 10 min read · 2,234 words

Google Ads automation has three rungs, and scripts sit on the middle one. Scripts handle everything else: custom logic, cross-campaign coordination, pulling in data from outside the platform.

Google's own scripts documentation lays out what that "everything else" covers. Scripts can read and write bids, budgets, ad status, labels, and a long list of campaign settings. They can call external URLs: a script can check an inventory feed, a weather API, or a pricing table and act on what it finds. None of that requires building against the full Google Ads API. It requires JavaScript, access to the account, and a clear idea of what needs to happen.

What scripts don't have is memory. Each run starts fresh unless the script is written to use PropertiesService, a method for storing state between executions. Without it, a script has no idea what it decided yesterday. That's a structural fact that reappears later as one of the clearest boundaries between what a script can do and what a reasoning system can do.

There's a quieter limitation tied to who can run these scripts. A script's authorization is tied to the Google Ads access level of whoever set it up. Google's documentation confirms that if the original author's access to the account is removed, the script stops running, though it stays listed and can be reauthorized by someone who still has access. That's a governance detail, not a technical curiosity, and it sets up a theme the rest of this piece keeps coming back to: scripts execute what they're told, but someone has to own them.

Why B2B accounts get more from scripts

B2B paid search runs on tighter budgets, with fewer conversions and sales cycles that stretch for months. Those three conditions, stacked together, make the cost of an undetected account problem much higher than it would be in a high-volume consumer account.

Start with volume. When conversions are scarce, each one carries more weight in the reporting. A keyword burning spend for a week without converting is a meaningful chunk of that month's budget, gone, in a way it wouldn't be in an account running thousands of conversions a month.

Then there's the lag. Sales cycles in B2B can run months long, so the data captured today won't inform a decision until well after the fact. So the data needs to be current and consistently formatted, and it needs to arrive without someone having to remember to pull it. A quarterly report built from a scramble of manual exports is a worse foundation for a sales cycle that already takes months to close.

And then there's the problem of budget exhausted after hours with nobody watching. Picture a campaign that exhausts its entire monthly budget on a Friday evening. Nobody notices until Monday morning. In a tightly controlled B2B budget, that's real money gone with nothing to show for it, and no chance to course-correct until the damage is already done. This is close to the exact scenario scripts exist to catch: a monitoring script checking spend pace doesn't take weekends off.

None of this means automation fixes a bad account. If the campaign targeting is off, or the offer doesn't match the audience, no amount of budget pacing or alerting will turn that around. Scripts catch execution failures. They don't evaluate whether the thing being executed is worth running. An AI agent environment built specifically for B2B paid media across Google and LinkedIn can help place scripts correctly within a broader growth strategy, rather than treating each one as an isolated fix solving a local problem in isolation from the pipeline goals it's supposed to serve.

The automation tasks where scripts consistently pay off in B2B accounts

Most of the recurring execution problems in a B2B account fall into four buckets: budget protection, performance alerting, search term hygiene, and cross-campaign reporting. Each has a working set of scripts built specifically for it.

Budget protection is the most direct response to the Friday scenario above. A label-based budget controller takes this further in multi-campaign accounts: campaigns get tagged with labels like "Brand," "Non-Brand," or "Competitor," and the script enforces a weekly cap per group. The Google Ads Scripts Store also lists a Check Monthly Budget script that keeps checking account spend against a defined monthly figure, and it can pause campaigns automatically if you want.

Performance alerting covers a wider range of silent failures. Account and campaign metrics out-of-limits alerts monitor any KPI (impressions, cost, conversions) and send an email when a threshold or percentage deviation is crossed. A smart bidding without target alert catches a specific configuration error: a campaign running on a smart bidding strategy with no target CPA or target ROAS set, quietly spending without the guardrail it's supposed to have. An expensive CPC detector scans search queries, keywords, products, and placements for extreme click costs and emails a notice when it finds one.

Search term hygiene is where Performance Max complicates things. Inside PMax, visibility into search terms is harder to get at by design. That's why Nils Rooijmans built a PMax non-converting search term alert script: it checks for search terms inside Performance Max that aren't converting, logs them to a Google Sheet, and sends an alert. As PMax takes up more of the budget in B2B accounts, wasted non-brand spend inside a PMax campaign is harder to see than in a standard search campaign, and more expensive to leave running once it's found.

Reporting rounds out the list. Campaign-level performance scripts pull data for a set lookback window and write it to a Google Sheet, so stakeholders get a consistent view without anyone manually exporting anything. For accounts managed across multiple client accounts under one parent account, executeInParallel() runs the same function across several child accounts at once, which is the standard method for cross-account audits.

One category is still taking shape. An AI-powered search term relevance checker, built by practitioner Charles Bannister, uses ChatGPT to compare search terms against ad copy and writes a relevance score to a Google Sheet. It's an early example of a script calling an LLM endpoint instead of running on pure rule-based logic, and it points at something larger: scripts can now reach out to third-party APIs, including language models, which stretches what "custom logic" can mean. That shift matters more for where the automation stack is headed than for what it delivers today.

The practical limits every practitioner hits with scripts

Scripts are reliable at single, well-defined tasks. The moment a task requires structural judgment, coordination across the account, or reasoning that spans more than one run, scripts hit a wall.

Some of the limits are baked into the environment itself. Scripts can't create campaigns, ad groups, or ads. The workaround is switching to GAQL reporting queries or splitting the work into batches using PropertiesService to track progress between runs. And without PropertiesService, there's no memory at all: a script that decided something last week has no record of having decided it, unless that decision was explicitly written down and read back in.

Authorization adds a quieter risk. A script's permissions match the access level of the person who authorized it. If a bid-adjustment script has a logic error, it doesn't produce a warning. It produces a bill.

The sharper limits, though, are about what scripts can decide, not just what they can execute. A script can flag that cost per lead has crossed a threshold. It can't tell anyone whether that's because of a bid issue, a creative problem, a landing page that stopped converting, or a shift in what the audience is actually looking for. That diagnosis needs context pulled from multiple systems at once, and the script doesn't have access to it.

A script can pause a keyword when cost per acquisition gets too high. Stacking that many conditions into a script means either writing increasingly tangled code to cover every combination, or building a layer of reasoning above the script that can weigh those conditions the way a person would. Scripts run on conditions someone already defined. They can't identify conditions nobody thought to write down yet.

There's a maintenance cost too, smaller than the structural limits but real. Someone has to write these scripts, keep them working as Google Ads interfaces and API fields change, and actually act on what they report. A reporting script that nobody reads is just code running in the background, producing a Sheet that sits unopened.

What sits above scripts: the strategy and judgment layer

Campaign structure, budget allocation by funnel stage, landing page diagnosis, and attribution design are the decisions that produce qualified pipeline in a B2B paid media program, and they sit above anything you can build a script to handle. These aren't tasks scripts have failed to automate yet, and they're not the kind of task a script architecture can take on.

Start with channel allocation. B2B paid media runs in two different modes. A script executes inside whatever account structure already exists. The decision about what that structure should be, which campaigns exist, how they're segmented, which keywords are even in scope, comes first and stays entirely outside script logic.

Attribution is where the judgment gets even more specific. The other is a steering ledger: the signal the platform gets right now about whether a lead is any good, so bidding algorithms can optimize toward the right thing in real time. Mixing those two ledgers breaks both of them. Cohort reporting fixes that by judging each month's spend against what its own leads eventually became. That's a framing decision, not a calculation, and no script performs it. Scripts also can't connect a click on an ad to an outcome in a CRM. That link has to be built deliberately, as its own piece of architecture, sitting outside the ad platform.

Diagnosing why pipeline has slowed down is the same kind of problem. A script can report that conversion rate dropped. It can't say whether that's the landing page, a shift in search terms, a competitor's new messaging, or an offer that stopped resonating. Figuring out which one it is takes visibility across systems the script was never built to see into, and tuning the ad platform when the real constraint is somewhere else wastes spend and burns time without fixing anything.

All of this eventually has to turn into something a CEO can look at. A useful view of paid media performance shows spend, qualified leads, opportunities, and pipeline value by channel, for cohorts old enough that their outcomes have actually played out, with younger cohorts clearly marked as still early and platform-reported conversions kept out of the headline numbers. Deciding what counts as "qualified," what to measure, and how to present uncertainty honestly is a set of judgment calls no script makes. Because each conversion in a B2B account carries outsized weight and budgets stay tight, undetected problems (an overspend event, data that's quietly drifted out of format, a configuration error nobody caught) compound faster than they would in a high-volume channel. Scripts catch those execution failures. Deciding which campaigns deserve to keep running, and how each one feeds into a pipeline goal, takes human judgment and accountability that automation alone doesn't supply.

How agentic systems bridge scripts and human judgment

Between script-level execution and human strategic judgment sits a gap: multi-variable reasoning that's too complex to hard-code into a script, but too repetitive to leave entirely to a person checking dashboards every morning. Pausing a keyword because CPA is high, the search term is off-target, and the traffic falls outside the ICP, all at the same time, is exactly that kind of reasoning. It's a job a human could do in a few minutes with the right dashboard open. It's also a job that needs doing across hundreds of keywords, every day. Agentic systems have started to step in there.

An agent built for this work doesn't just execute a fixed rule the way a script does. It can look at several signals together, weigh them against each other, and take an action, then explain the reasoning behind it in a way a person can check. That's a meaningfully different capability than a script's if/then logic, and it's the layer Thunder is built around: AI agents that handle research, monitoring, launch, and optimization across Google and LinkedIn campaigns, built specifically for B2B paid media rather than retrofitted from a general-purpose automation tool.

None of that replaces the judgment layer described above. Deciding how to split budget between demand capture and demand creation, designing an attribution framework that keeps reporting and steering ledgers separate, and presenting a CEO-ready view of pipeline value are still calls a person has to own. What's changed is the size of the space between "a script that runs a fixed rule" and "a person manually checking every account." Agentic systems are shrinking that space, handling the reasoning that's too tangled for a script but too repetitive to be a good use of a strategist's day. Scripts still cover a large share of the execution layer, and they do it reliably. What agents are starting to cover is everything in between: the daily judgment calls that used to require someone opening the account, reading the signals, and deciding what to do about them, now handled by a system built to do exactly that, while the strategic calls stay exactly where they've always belonged.

Sources

  1. Using scripts to make automated changes - Google Ads Help
  2. Thunder | AI Agents for Growth Marketing

More in AI in Paid Search