---
title: "Google Ads Landing Page 404 & Redirect Chain Monitor Script (GAQL)"
description: "Scheduled GAQL script checking HTTP response codes, redirect chains and soft-404 signatures across all active ad final URLs."
canonical: "https://gordongeraghty.com/resources/landing-page-404-monitor-script"
type: "resource"
date: "2026-08-01T08:00:00+10:00"
updated: "2026-09-24T15:40:35+10:00"
---



# Google Ads Landing Page 404 & Redirect Chain Monitor Script (GAQL)

**Gordon Geraghty:** Google Ads Landing Page 404 & Redirect Chain Monitor Script (GAQL). Scheduled GAQL script checking HTTP response codes, redirect chains and soft-404 signatures across all active ad final URLs.

**Category: Performance Media · Type: script · Level: beginner · Licence: MIT**

## Eliminating Paid Traffic to Broken URLs

E-commerce product discontinuations and CMS migrations frequently orphan landing pages while paid ads continue spending. This script checks every live ad URL hourly and delivers an immediate notification when a 404 or 500 error code occurs.

### GAQL Landing Page 404 Monitor

```javascript
/**
 * Google Ads Landing Page 404 & Status Monitor (GAQL)
 * Author: Gordon Geraghty - Head of Performance Media
 * Licence: MIT
 * Filter: campaign.status = "ENABLED" AND campaign.serving_status = "SERVING"
 */

const CONFIG = {
  EMAIL: 'alerts@example.com',
};

function main() {
  Logger.log('Scanning active final URLs for broken pages...');

  const query =
    'SELECT ad_group_ad.ad.final_urls, campaign.name, ad_group.name ' +
    'FROM ad_group_ad ' +
    'WHERE campaign.status = "ENABLED" ' +
    'AND campaign.serving_status = "SERVING" ' +
    'AND ad_group.status = "ENABLED" ' +
    'AND ad_group_ad.status = "ENABLED"';

  const seen = {};
  const broken = [];
  const rows = AdsApp.search(query);

  while (rows.hasNext()) {
    const row = rows.next();
    const urls = row.adGroupAd.ad.finalUrls || [];
    const camp = row.campaign.name;
    const adg = row.adGroup.name;

    urls.forEach(function(u) {
      if (seen[u]) return;
      seen[u] = true;
      try {
        const response = UrlFetchApp.fetch(u, { muteHttpExceptions: true });
        const code = response.getResponseCode();
        if (code >= 400) {
          broken.push({ url: u, code: code, campaign: camp, adGroup: adg });
        }
      } catch (e) {
        broken.push({ url: u, code: 'FETCH_ERROR: ' + e.message, campaign: camp, adGroup: adg });
      }
    });
  }

  Logger.log('Scanned ' + Object.keys(seen).length + ' unique URLs. Broken found: ' + broken.length);

  if (broken.length > 0 && CONFIG.EMAIL) {
    let msg = 'Google Ads Broken Landing Page Alert:\n\n';
    broken.forEach(function(b) {
      msg += 'Status ' + b.code + ' on: ' + b.url + '\n';
      msg += 'Campaign: ' + b.campaign + ' | Ad Group: ' + b.adGroup + '\n\n';
    });
    MailApp.sendEmail(CONFIG.EMAIL, 'Google Ads Broken URL Alert (' + broken.length + ' broken URLs)', msg);
  }
}
```

### Changelog
- **1.0.0:** Initial release with UrlFetchApp status code verification and deduplicated URL checking.

**Tags:** Google Ads, GAQL Scripts

[Canonical URL](https://gordongeraghty.com/resources/landing-page-404-monitor-script)
