Conversion drop and 404 watchdog script for Google Ads
A free, read‑only Google Ads Script that compares each campaign’s conversions with the period before, leaving out the newest days that are still filling in, and requests each live final URL to catch 404 and server errors. It runs in one account or across a manager account. 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
landing-
6 KB · 214 lines
- Reads
- campaignad_group_ad
- Writes
- Your Google SheetOptional email
- Changes in Google Ads
- None
- Runs in
- Account or manager
- Suggested frequency
- Daily
- License
- MIT
/** * Landing-Page 404 & Conversion-Drop Watchdog * Read-only Google Ads Script (MIT License) * Copyright (c) 2026 Parallel AI, Inc. * https://www.withparallel.ai * Docs & configurator: * https://www.withparallel.ai/scripts/conversion-drop-watchdog * 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 = { WINDOW_DAYS: 7, LAG_SKIP_DAYS: 2, CONVERSION_DROP_ALERT_PCT: 35, MIN_BASELINE_CONVERSIONS: 10, CHECK_FINAL_URLS: true, MAX_URLS_PER_RUN: 200, SPREADSHEET_URL: "", EMAIL_RECIPIENTS: "",};Lines 26 to 214The script body, the same for every setting
function main() { const dropRows = []; const brokenRows = []; const urlState = { checked: 0, seen: {} }; if (typeof AdsManagerApp !== "undefined") { const accounts = AdsManagerApp.accounts().get(); while (accounts.hasNext()) { const account = accounts.next(); AdsManagerApp.select(account); auditCurrentAccount( account.getName(), dropRows, brokenRows, urlState ); } } else { const name = AdsApp.currentAccount().getName(); auditCurrentAccount(name, dropRows, brokenRows, urlState); } const sheet = openOrCreateSheet( CONFIG.SPREADSHEET_URL, "Parallel AI - Conversion Drop & 404 Watchdog" ); writeTab(sheet, "Conversion drops", [ "Account", "Campaign", "Prior conv", "Recent conv", "Change", "Recent CPA", ], dropRows); if (CONFIG.CHECK_FINAL_URLS) { writeTab(sheet, "Broken URLs", [ "Account", "Campaign", "Ad group", "Final URL", "HTTP status", ], brokenRows); } const totalAlerts = dropRows.length + brokenRows.length; if (CONFIG.EMAIL_RECIPIENTS && totalAlerts > 0) { MailApp.sendEmail( CONFIG.EMAIL_RECIPIENTS, "Watchdog alert: " + dropRows.length + " drops, " + brokenRows.length + " broken URLs", "Review watchdog sheet in: " + sheet.getUrl() ); } Logger.log("Sheet URL: " + sheet.getUrl());}function auditCurrentAccount( accountName, dropRows, brokenRows, urlState) { const tz = AdsApp.currentAccount().getTimeZone(); const ranges = buildLagSafeRanges( CONFIG.WINDOW_DAYS, CONFIG.LAG_SKIP_DAYS, tz ); const prior = readCampaignConversions(ranges.priorStart, ranges.priorEnd); const recent = readCampaignConversions( ranges.recentStart, ranges.recentEnd ); Object.keys(prior).forEach((id) => { const base = prior[id]; if (base.conv < CONFIG.MIN_BASELINE_CONVERSIONS) return; const cur = recent[id] || { name: base.name, conv: 0, cost: 0 }; const dropPct = ((base.conv - cur.conv) / base.conv) * 100; if (dropPct >= CONFIG.CONVERSION_DROP_ALERT_PCT) { const cpa = cur.conv > 0 ? round2(cur.cost / cur.conv) : "n/a"; dropRows.push([ accountName, base.name, round1(base.conv), round1(cur.conv), "-" + round1(dropPct) + "%", cpa, ]); } }); if (CONFIG.CHECK_FINAL_URLS) { checkActiveFinalUrls(accountName, brokenRows, urlState); }}function readCampaignConversions(startDate, endDate) { const query = [ "SELECT campaign.id, campaign.name,", " metrics.conversions, metrics.cost_micros", "FROM campaign", "WHERE segments.date BETWEEN '" + startDate + "' AND '" + endDate + "'", " AND campaign.status = 'ENABLED'", ].join("\n"); const map = {}; const rows = AdsApp.search(query); while (rows.hasNext()) { const row = rows.next(); const c = row.campaign || {}; const m = row.metrics || {}; if (!map[c.id]) map[c.id] = { name: c.name, conv: 0, cost: 0 }; map[c.id].conv += Number(m.conversions || 0); map[c.id].cost += Number(m.costMicros || 0) / 1e6; } return map;}function checkActiveFinalUrls(accountName, brokenRows, urlState) { const query = [ "SELECT campaign.name, ad_group.name, ad_group_ad.ad.final_urls", "FROM ad_group_ad", "WHERE campaign.status = 'ENABLED'", " AND ad_group.status = 'ENABLED'", " AND ad_group_ad.status = 'ENABLED'", " AND segments.date DURING LAST_7_DAYS", " AND metrics.clicks > 0", ].join("\n"); const rows = AdsApp.search(query); while (rows.hasNext() && urlState.checked < CONFIG.MAX_URLS_PER_RUN) { const row = rows.next(); const urls = (((row.adGroupAd || {}).ad || {}).finalUrls) || []; for (let i = 0; i < urls.length; i += 1) { const url = String(urls[i] || ""); if (!url || urlState.seen[url]) continue; if (urlState.checked >= CONFIG.MAX_URLS_PER_RUN) break; urlState.seen[url] = true; urlState.checked += 1; const code = fetchHttpStatus(url); if (code >= 400 || code === 0) { brokenRows.push([ accountName, row.campaign ? row.campaign.name : "", row.adGroup ? row.adGroup.name : "", url, code === 0 ? "Network error" : String(code), ]); } } }}function fetchHttpStatus(url) { try { const res = UrlFetchApp.fetch(url, { method: "get", muteHttpExceptions: true, followRedirects: true, }); return res.getResponseCode(); } catch (err) { return 0; }}function buildLagSafeRanges(windowDays, lagSkipDays, timeZone) { const today = new Date(); const shift = (daysAgo) => { const d = new Date(today.getTime() - daysAgo * 86400000); return Utilities.formatDate(d, timeZone, "yyyy-MM-dd"); }; const recentEndOffset = 1 + lagSkipDays; const recentStartOffset = recentEndOffset + windowDays - 1; const priorEndOffset = recentStartOffset + 1; const priorStartOffset = priorEndOffset + windowDays - 1; return { recentStart: shift(recentStartOffset), recentEnd: shift(recentEndOffset), priorStart: shift(priorStartOffset), priorEnd: shift(priorEndOffset), };}function round2(n) { return Math.round(n * 100) / 100; }function round1(n) { return Math.round(n * 10) / 10; }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 a Google Ads account or a manager account, 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. Daily suits this script.
What it reads and the rules it follows
Two queries, through AdsApp.search. One on campaign for conversions and cost in each window, and one on ad_group_ad for the final URLs of enabled ads that had a click in the last 7 days. It then requests each of those URLs once and reads the status code.
- Google Ads reports the Conversions column on the click date, so the most recent days understate conversions until late clicks convert.OfficialGoogle Ads Help, Understand your conversion tracking data
- Skipping today and the newest 2 completed calendar days before comparing current and prior windows avoids false conversion‑drop alerts caused by normal conversion lag.Practitioner rule
- Active ad final URLs are checked with HTTP GET via UrlFetchApp (read‑only) to catch 404 and 5xx landing‑page errors before spend continues to broken pages.Practitioner rule
The Sheet it writes
Two tabs. Conversion drops lists each campaign whose conversions fell by the alert percentage or more, with both counts, the change and the recent cost per conversion. Broken URLs lists each final URL that answered with a status of 400 or higher, or did not answer. With an alert email set, Google Ads Scripts sends one from your account when a run has a row on either tab.
| Account | Campaign | Prior conv | Recent conv | Change | Recent CPA |
|---|---|---|---|---|---|
| Meridian Solar & Storage | Search | Battery Backup | 34 | 14 | -58.8% | 192.00 |
| Meridian Solar & Storage | Search | Residential Solar | 52 | 32 | -38.5% | 130.00 |
What it cannot tell you
- Google Ads counts a conversion on the day of the click, so the newest days keep rising. The script leaves out today and the newest 2 completed days unless you change the buffer. The buffer is a practitioner rule, not a Google rule.
- A campaign needs the baseline number of conversions in the earlier window. A smaller campaign is skipped.
- The two windows follow each account’s own time zone in Google Ads.
- URL checks cover enabled ads that had a click in the last 7 days, up to the cap in the settings. A page that loads with a 200 and shows an error passes.
- Some sites answer a script’s request differently from a visitor’s, so open a flagged URL in a browser.
- It pauses nothing. A broken page keeps taking clicks until someone acts on the row.
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, requests your own final URLs to read their status codes, 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 says that conversions fell. Parallel AI is the AI agent platform for Google Ads. A Google Ads AI agent reads conversion actions, change history and search terms across every connected account, traces the drop to what changed, and writes up the evidence.
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 pause ads that point at a broken page?
No. It reads with AdsApp.search, requests each final URL and writes to a Google Sheet. It has no call that pauses an ad, a keyword or a campaign.
Why does it skip the newest days?
Google Ads counts a conversion on the day of the click, and a click can convert days later. The newest days are still filling in, so comparing them with a finished week shows a drop that is not there. Skipping 2 days is a practitioner rule you can change.
Does it work in a manager account?
Yes. In a manager account it walks each client account and writes them all to one Sheet. In a single account it checks that account.
What counts as a broken URL?
A final URL that answers with a status of 400 or higher, such as 404 or 500, or that does not answer the request.
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.
Trace a conversion drop to what changed
Connect Google Ads and Parallel AI reads conversion actions, change history and search terms across your connected accounts, and writes up what changed with the evidence.
Starter $20, Pro $60 and Max $200 a month
You add a card to start the trial, then connect Google Ads.