Managing Google Ads by hand means checking the same things over and over: Is spend on pace? Did a landing page break? Are there new search terms worth adding? Humans are bad at repetitive checks, and accounts lose money in the gaps between them. Google Ads scripts, small JavaScript programs that run inside your account on a schedule, handle those checks reliably. This article covers five scripts every account manager should have running, with what each does, why it matters, conceptual pseudo-code, and the impact you can expect.
Scripts query account data using the same query language described in our article on querying Google Ads data with GAQL. Pseudo-code below is conceptual; adapt it to your own account structure and test in preview mode first.
- Budget pacing alert
- Search term miner
- Anomaly detector
- Getting started safely
1. Budget pacing alert
What it does: Compares month-to-date spend with the expected pace for the day of the month and emails you when spend is 20% or more off track, in either direction.
Why you need it: Overspending drains budgets before the month ends; underspending wastes opportunity and often signals a disapproval, limited bid strategy, or broken tracking.
expected = monthly_budget * (day_of_month / days_in_month)
actual = query("SELECT metrics.cost_micros ... DURING THIS_MONTH") / 1e6
variance = (actual - expected) / expected
if abs(variance) >= 0.20:
email("Pacing alert", campaign, expected, actual, variance)
Expected impact: catches pacing problems within a day instead of at month-end review.
2. Broken URL checker
What it does: Reads the final URLs of all enabled ads and keywords, requests each one, and reports anything returning a 404, 500, or redirecting to an unexpected page.
Why you need it: Sending paid traffic to a dead page is one of the most expensive silent mistakes in advertising. Website changes, product removals, and migrations break URLs without anyone telling the ads team.
urls = unique(final_urls of enabled ads and keywords)
for url in urls:
status = fetch(url).status
if status >= 400 or redirects_off_domain(url):
broken.append(url, status)
if broken: email(report); optionally pause_ads(broken)
Expected impact: prevents days of wasted clicks. Tracking breaks are a related class of silent failure; see our guide to diagnosing conversion tracking disasters.
Why you need it: Sending paid traffic to a dead page is one of the most expensive silent mistakes in advertising.
3. Search term miner
What it does: Scans the search terms report for queries that produced conversions but are not yet added as keywords, and lists them for review. A second pass flags high-spend, zero-conversion terms as negative candidates.
Why you need it: Search terms are where intent really shows up. Adding proven converters as exact match keywords gives you control over bids and ad copy, while negatives stop waste.
terms = query("SELECT search_term_view.search_term, metrics.conversions, metrics.cost_micros
FROM search_term_view DURING LAST_30_DAYS")
for t in terms:
if t.conversions >= 2 and t.term not in existing_keywords:
add_candidate_keywords(t)
if t.cost > 30 and t.conversions == 0:
add_candidate_negatives(t)
sheet.append(candidates)
Expected impact: consistently identifies 5 to 15 useful keyword and negative additions a month in active accounts, usually reducing wasted spend by several percent.
What it does: Scans the search terms report for queries that produced conversions but are not yet added as keywords, and lists them for review.
4. Bid adjustment optimizer
What it does: Analyzes conversion rate and cost per conversion by device, location, and hour-day schedule, then proposes or applies bid adjustments within safe limits.
Why you need it: Performance varies widely. Mobile may convert at half the rate of desktop, or Saturdays may produce the cheapest leads. Adjusting bids by segment concentrates budget where it works. Note that fully automated bidding strategies handle some of this; the script is most useful with manual or enhanced CPC campaigns, or to audit what smart bidding is doing.
for segment in devices + top_locations + day_hour_blocks:
cpa_ratio = segment.cpa / campaign.cpa
adjustment = clamp(1 / cpa_ratio, 0.7, 1.3)
if segment.conversions >= 15: # enough data
propose_adjustment(segment, adjustment)
Expected impact: typically 5 to 15% improvement in cost per conversion on manual campaigns. Always require a minimum number of conversions before adjusting, and cap changes to avoid overreacting to noise.
Want expert help with this? Let's make it happen.
Get a Free Consultation5. Anomaly detector
What it does: Compares yesterday's CTR, CPC, spend, and conversions against a rolling baseline, such as the same weekday over the last four weeks, and flags statistically unusual changes.
Why you need it: Sudden shifts usually mean something broke: a competitor surge, a disapproved ad, a tracking tag removed, or a bid strategy going haywire. Performance Max in particular can shift quickly, as explained in when Performance Max campaigns work.
for metric in [ctr, cpc, spend, conversions]:
baseline = mean(last_4_same_weekdays(metric))
spread = stdev(last_4_same_weekdays(metric))
z = (yesterday(metric) - baseline) / spread
if abs(z) > 2.5 and enough_volume:
alert(metric, yesterday, baseline, z)
Expected impact: cuts the time to notice a problem from days to hours, which on a $5,000-a-month account can save hundreds of dollars per incident.
Manual vs scripted time
| Task | Manual time per week | With script | Frequency of check |
|---|---|---|---|
| Budget pacing review | 30 minutes | 2 minutes (read alert) | Daily instead of weekly |
| Broken URL check | 45 minutes | 0 minutes (automatic) | Daily instead of monthly |
| Search term mining | 60 minutes | 15 minutes (review list) | Weekly |
| Bid adjustment analysis | 90 minutes | 20 minutes (approve changes) | Weekly |
| Anomaly monitoring | 40 minutes | 5 minutes (read alerts) | Daily instead of weekly |
| Total | about 4.5 hours | about 45 minutes | Much faster detection |
Getting started safely
- Begin with the read-only scripts: pacing, URL checks, search term reports, and anomaly alerts.
- Use preview mode and log output before enabling any script that changes the account.
- Add change limits and email logs for every automated edit.
- Keep a human in the loop for bid and budget changes until you trust the logic.
Scripts give you consistency, but they do not replace strategy. If you would like these monitors set up and tuned for your account, see our Google Ads management service.
Related reading: GAQL: Querying Google Ads Data as a Developer | Conversion Tracking Disasters: Diagnose and Recover | Performance Max Campaigns: When They Work
Want these automations running on your account? Explore my Google Ads management service or get in touch for a free consultation.



Frequently Asked Questions
Do I need to know how to code to use Google Ads scripts?
Basic JavaScript helps, but many ready-made scripts exist that you can paste in and configure. For custom logic or anything that changes your account automatically, have someone experienced review it first.
Are Google Ads scripts safe to run?
Read-only reporting scripts are very safe. Scripts that change bids, budgets, or statuses should be tested in preview mode, limited with caps, and logged, because errors can spend money quickly.
How often should scripts run?
Pacing, URL checks, and anomaly detection are best run daily. Search term mining and bid analysis are usually weekly, since they need enough data to be meaningful.
Full-stack developer specializing in Django, AI automation, and Google Ads management. Building production SaaS platforms and custom web applications for businesses across the US.