Wasted spend search term script for Google Ads
A free, read‑only Google Ads Script that finds search terms with clicks, cost and no conversions, checks each one against your active keywords, and writes a negative keyword list laid out for Google Ads Editor. MIT licensed.
Configures the script in this tab. Copy or download the MIT .js file and paste it into Google Ads Scripts. Where your data goes
zero-
5 KB · 171 lines
- Reads
- search_term_viewad_group_criterion
- Writes
- Your Google SheetOptional email
- Changes in Google Ads
- None
- Runs in
- One account
- Suggested frequency
- Weekly
- License
- MIT
/** * Zero-Conversion Search Term Wasted Spend Auditor * Read-only Google Ads Script (MIT License) * Copyright (c) 2026 Parallel AI, Inc. * https://www.withparallel.ai * Docs & configurator: * https://www.withparallel.ai/scripts/wasted-spend-search-term-auditor * Repository: * https://github.com/parallel-ai-inc/google-ads-scripts * * Changes in Google Ads: None (reads via AdsApp.search). * Google Ads is a trademark of Google LLC. Parallel AI is * not affiliated with or endorsed by Google. */const CONFIG = { LOOKBACK_DAYS: "LAST_30_DAYS", MIN_COST: 50, MIN_CLICKS: 10, PROPOSED_MATCH_TYPE: "EXACT", SPREADSHEET_URL: "", EMAIL_RECIPIENTS: "",};Lines 24 to 171The script body, the same for every setting
function main() { const activeKeywords = loadActiveKeywords(); const query = [ "SELECT campaign.name, ad_group.name,", " search_term_view.search_term, search_term_view.status,", " metrics.clicks, metrics.cost_micros, metrics.conversions", "FROM search_term_view", "WHERE segments.date DURING " + CONFIG.LOOKBACK_DAYS, " AND metrics.conversions = 0", "ORDER BY metrics.cost_micros DESC", ].join("\n"); const wastedRows = []; const editorRows = []; const seenEditor = {}; const criterionType = CONFIG.PROPOSED_MATCH_TYPE === "PHRASE" ? "Campaign Negative Phrase" : "Campaign Negative Exact"; const rows = AdsApp.search(query); while (rows.hasNext()) { const row = rows.next(); const m = row.metrics || {}; const clicks = Number(m.clicks || 0); const cost = Number(m.costMicros || 0) / 1e6; if (clicks < CONFIG.MIN_CLICKS || cost < CONFIG.MIN_COST) continue; const st = row.searchTermView || {}; if (st.status === "EXCLUDED" || st.status === "ADDED_EXCLUDED") { continue; } const campaign = row.campaign ? row.campaign.name : ""; const adGroup = row.adGroup ? row.adGroup.name : ""; const term = String(st.searchTerm || ""); const conflict = blocksActiveKeyword( term, CONFIG.PROPOSED_MATCH_TYPE, activeKeywords[campaign] || [] ); wastedRows.push([ campaign, adGroup, term, clicks, Math.round(cost * 100) / 100, conflict ? "Hold: blocks " + conflict : "Safe for Editor", ]); const dedupKey = campaign + "\0" + term.toLowerCase(); if (!conflict && !seenEditor[dedupKey]) { seenEditor[dedupKey] = true; editorRows.push([campaign, "", term, criterionType]); } } const sheet = openOrCreateSheet( CONFIG.SPREADSHEET_URL, "Parallel AI - Wasted Spend Auditor" ); writeTab(sheet, "Wasted search terms", [ "Campaign", "Ad group", "Search term", "Clicks", "Cost", "Conflict check", ], wastedRows); writeTab(sheet, "Editor import", [ "Campaign", "Ad Group", "Keyword", "Criterion Type", ], editorRows); if (CONFIG.EMAIL_RECIPIENTS && editorRows.length > 0) { MailApp.sendEmail( CONFIG.EMAIL_RECIPIENTS, "Wasted spend audit: " + editorRows.length + " Editor rows", "Review safe negative candidates in: " + sheet.getUrl() ); } Logger.log("Sheet URL: " + sheet.getUrl());}function loadActiveKeywords() { const query = [ "SELECT campaign.name, ad_group_criterion.keyword.text", "FROM ad_group_criterion", "WHERE ad_group_criterion.type = 'KEYWORD'", " AND ad_group_criterion.negative = FALSE", " AND ad_group_criterion.status = 'ENABLED'", ].join("\n"); const byCampaign = {}; const rows = AdsApp.search(query); while (rows.hasNext()) { const row = rows.next(); const camp = row.campaign ? row.campaign.name : ""; const kw = (row.adGroupCriterion || {}).keyword || {}; if (!kw.text) continue; if (!byCampaign[camp]) byCampaign[camp] = []; byCampaign[camp].push(tokenize(kw.text)); } return byCampaign;}function tokenize(text) { return String(text || "").toLowerCase().trim().split(/\s+/) .filter(Boolean);}function blocksActiveKeyword(negText, matchType, campaignKws) { const neg = tokenize(negText); for (let i = 0; i < campaignKws.length; i += 1) { const kw = campaignKws[i]; const same = neg.length === kw.length && neg.every((w, idx) => w === kw[idx]); if (matchType === "EXACT" && same) return kw.join(" "); if (matchType === "PHRASE" && containsPhrase(kw, neg)) { return kw.join(" "); } } return null;}function containsPhrase(words, phrase) { if (phrase.length === 0 || phrase.length > words.length) return false; for (let s = 0; s + phrase.length <= words.length; s += 1) { let ok = true; for (let o = 0; o < phrase.length; o += 1) { if (words[s + o] !== phrase[o]) { ok = false; break; } } if (ok) return true; } return false;}function safeCell(val) { if (typeof val !== "string") return val; if (/^[=+@]/.test(val) || /^-[^0-9.]/.test(val)) return "'" + val; return val;}function openOrCreateSheet(url, fallbackName) { return url ? SpreadsheetApp.openByUrl(url) : SpreadsheetApp.create(fallbackName);}function writeTab(spreadsheet, name, headers, rows) { let tab = spreadsheet.getSheetByName(name); if (!tab) tab = spreadsheet.insertSheet(name); tab.clearContents(); const safeRows = rows.map((r) => r.map(safeCell)); const data = [headers].concat(safeRows); tab.getRange(1, 1, data.length, headers.length).setValues(data);}Install it in Google Ads
- Set the thresholds on this page, then copy the script or download the .js file.
- In Google Ads, open Tools, then Bulk actions, then Scripts, and add a new script.
- Paste the script over the starter code and give it a name.
- Google Ads asks you to authorize the script the first time. That happens in your own account, under your Google login.
- Choose Preview. Copy the Google Sheet URL from the last log line and paste it into SPREADSHEET_URL so scheduled runs reuse one Sheet instead of creating a new one each time.
- Set its frequency on the Scripts page. Weekly suits this script.
What it reads and the rules it follows
Two queries, through AdsApp.search. One on search_term_view for terms with no conversions in the window, and one on ad_group_criterion for the enabled keywords each campaign bids on. Cost is in the account’s own currency.
- Negative keywords do not match close variants or plurals, so each singular and plural form requires its own negative entry.OfficialGoogle Ads Help, About negative keywords
- Google Ads allows up to 1,000 account‑level negative keywords per account.OfficialGoogle Ads Help, About account-level negative keywords
- Only non‑excluded search terms with zero conversions above your spend and click thresholds are tested against active keywords under exact or phrase rules before entering the campaign‑level Editor tab.Practitioner rule
The Sheet it writes
Two tabs. Wasted search terms lists each term past both thresholds, with its clicks, its cost and the result of the conflict check. Editor import holds the terms that passed, in the four columns Google Ads Editor reads, which are Campaign, Ad Group, Keyword and Criterion Type. With an alert email set, Google Ads Scripts sends one from your account when a run has rows to import.
| Campaign | Search term | Clicks | Cost | Conflict check |
|---|---|---|---|---|
| Search | Dental Implants | free dental implant clinical trial | 28 | 196.40 | Safe for Editor |
| Search | Dental Implants | dental implant hygienist jobs | 19 | 124.80 | Safe for Editor |
| Search | Emergency Dental | emergency dentist near me | 16 | 112.00 | Hold: blocks emergency dentist near me |
| Search | Cosmetic | snap on veneers amazon | 14 | 78.60 | Safe for Editor |
What it cannot tell you
- The conflict check compares a proposed negative with the enabled keywords of its own campaign. An exact negative is held back when it equals a keyword. A phrase negative is held back when a keyword contains it in the same order.
- It proposes exact or phrase negatives at the campaign level. It does not propose broad negatives or shared lists.
- A negative keyword does not block close variants or plurals, so each form of a term needs its own row.
- The test is no conversions inside the window. A term whose conversion is recorded after the run still reads as zero.
- It adds no negative keyword. The Editor import tab is a list to bring in yourself.
Where your data goes
This page builds the script’s text in your browser tab. It asks for no login and connects to no Google Ads account.
A Sheet address or an alert email you type goes into the script’s text, so the copy is ready to paste. The link you copy holds thresholds and switches only, in the part of the address after the # sign, which a browser does not send when it requests a page.
Once pasted, the script runs inside Google Ads Scripts under your Google account. It reads the account, writes to your Google Sheet and sends the optional email from your account. Nothing in it calls Parallel AI.
Site analytics are separate from the script. If you accepted analytics cookies, they record how pages on this site are used, which can include what is on the screen. The privacy policy covers site analytics and your consent settings.
On a live account
A script lists the terms that cleared two thresholds. Parallel AI is the AI agent platform for Google Ads. A Google Ads AI agent reads search terms across every connected account, decides which to exclude and why, and adds the negatives.
Questions and answers
Is the script free?
Yes. It is open source under the MIT license, with no login, no trial and no email address. The whole file is on this page and on GitHub.
Does the script add negative keywords?
No. It reads with AdsApp.search and writes to a Google Sheet. It has no call that adds a negative, pauses a keyword or changes a bid.
How does it avoid blocking an active keyword?
Before a term reaches the Editor import tab, the script tests it as a negative against the enabled keywords of the same campaign. A term that would block one is marked Hold on the first tab and left off the import.
How do the rows get into Google Ads Editor?
Copy the Editor import tab with its header row. In Google Ads Editor, choose Account, then Import, then Paste text, and match the four columns.
Does a negative keyword block plurals?
No. A negative keyword does not match close variants, so a singular and a plural each need their own negative.
Does the script need access to my Google account?
Google Ads asks you to authorize the script the first time it runs. That grant is between you and Google, inside your own account. Parallel AI receives nothing.
Google Ads is a trademark of Google LLC. Parallel AI is not affiliated with or endorsed by Google.
Work through search terms on the live account
Connect Google Ads and Parallel AI reads search terms across your connected accounts, gives each exclusion its reason, and writes the result to a Sheet.
Starter $20, Pro $60 and Max $200 a month
You add a card to start the trial, then connect Google Ads.