Google Ads script

Broken landing pages (404 checker)

Read-only. Requests the final URLs of all enabled ads and logs any that respond with an error (4xx/5xx) — so you catch dead landing pages before they waste budget. Deduplicates URLs.

← All scripts
Read-onlyTry the script in a demo account — see the log, the changes and what it means.
Demo account
Script · 404 checker
Not run yet
function main() {
// Read-only: checks the final URLs of enabled ads for broken responses (4xx/5xx).
var checked = {};
var broken = 0;
var ads = AdsApp.ads()
.withCondition('Status = ENABLED')
.withCondition('CampaignStatus = ENABLED')
.get();
while (ads.hasNext()) {
var ad = ads.next();
var url = ad.urls().getFinalUrl();
if (!url || checked[url]) continue;
checked[url] = true;
var status;
try {
var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true, followRedirects: true });
status = response.getResponseCode();
} catch (e) {
status = 'ERROR: ' + e;
}
if (typeof status === 'string' || status >= 400) {
broken++;
Logger.log(status + ' ' + url + ' (' + ad.getCampaign().getName() + ')');
}
}
Logger.log('Done. Checked ' + Object.keys(checked).length + ' unique URLs, ' + broken + ' broken.');
}
Press Preview to see what the script does in the demo account.

Simulated run in a fictional demo account. The script’s real code runs in your browser against sample data — nothing connects to Google Ads, no emails are sent and no sheets are created.

How to run the script
  1. Google Ads → Tools → Bulk actions → Scripts.
  2. Click + and paste the code. Authorize when asked.
  3. Run a preview first and read the log.
  4. Schedule the script if you want it to run regularly.
SEOZ runs these checks for you — automatically, with alerts when something breaks.
Try the guided demo →More scripts