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.
By the SEOZ team · Updated June 12, 2026
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.');
}