GAQL Script for Intraday Conversion Rate Drop Alerts

Build a custom GAQL script to detect sudden intraday conversion rate collapses across search terms. Includes ready-to-use code, thresholds, and webhook alerts.

By AdTurbo Team · 2026-12-02

A sudden collapse in conversion rate on a top-performing search term can drain thousands of dollars in ad spend before standard daily reporting catches it. Most PPC managers discover conversion anomalies 24 to 48 hours after the damage occurs, when they review daily totals or notice an inflated Cost Per Acquisition (CPA). By querying the Google Ads API using Google Ads Query Language (GAQL) via Google Ads Scripts, you can monitor search term efficiency dynamically and trigger immediate alerts before bad traffic burns your daily budget.

Whether an intraday crash stems from broken landing page tags, checkout gateway errors, broken tracking pixels, or abrupt algorithmic traffic shifts, waiting for an automated bidding strategy to self-correct is a costly mistake. In this technical walkthrough, you will learn how to design, code, test, and deploy a robust GAQL script that identifies sudden intraday conversion collapses and pushes instant alerts to your Slack, Microsoft Teams, or custom webhook.

---

Why Traditional Conversion Alerts Fail During Intraday Collapses

Most account managers rely on native automated rules inside Google Ads or look at historical dashboards once every morning. While this cadence works for macro-level account hygiene, it fails to protect against sudden real-time failures.

The Delay of Standard Daily Reporting

Native Google Ads Automated Rules run on rigid schedules—typically once daily at midnight or early morning. If an e-commerce checkout page crashes at 10:00 AM on a Friday during peak volume, an automated rule scheduled for 1:00 AM Saturday allows 15 hours of unmitigated spend on non-converting traffic. Real-time alerting requires scripts capable of running on hourly cycles, comparing rolling intraday performance against baseline metrics.

Conversion Lag vs. Operational Breakdowns

Smart Bidding handles gradual algorithmic drift, but it cannot differentiate between benign conversion lag (users who click now and convert 6 hours later) and an operational emergency (such as a 500 server error on your payment gateway). Relying on automated rules without statistical baselines results in two extremes: either continuous false-positive alerts caused by natural daytime conversion lag, or total silence while thousands of dollars exit your bank account.

To manage campaigns effectively without monitoring screens 24/7, modern accounts incorporate automated intelligence. Platforms like AdTurbo deploy machine learning agents that continuously evaluate performance fluctuations and apply safeguards in real time. If you run custom code, building your own gaql script conversion rate drop alert is your first line of defense.

---

The Anatomy of a GAQL Query for Search Term Performance

Google Ads Query Language (GAQL) is an SQL-like syntax used to query the Google Ads API and Google Ads Scripts environment (AdsApp.search()). Unlike legacy AWQL (AdWords Query Language), GAQL operates on strict resource schemas, field naming, and segmentation rules.

Core Resources and Attributed Fields

To identify conversion drops at the query level, we primarily query the searchtermview resource. This resource links actual user search queries to campaigns, ad groups, and performance metrics.

Here are the critical fields required for conversion crash detection:

• searchtermview.searchterm: The exact query entered by the user.

• searchtermview.status: Shows whether the query is added, excluded, or none.

• campaign.id & campaign.name: Identifies the parent campaign.

• adgroup.id & adgroup.name: Identifies the ad group context.

• metrics.clicks: Click volume generated by the query.

• metrics.conversions: Recorded conversion actions.

• metrics.conversionsvalue: Total value generated.

• metrics.costmicros: Ad spend represented in micro-units (divide by 1,000,000 for local currency).

• segments.date: Partition dates for baseline and intraday comparisons.

Constructing the Query

A production-ready GAQL query to extract search term performance across today's traffic looks like this:

sql

SELECT

campaign.id,

campaign.name,

adgroup.id,

adgroup.name,

searchtermview.searchterm,

metrics.clicks,

metrics.conversions,

metrics.costmicros

FROM searchtermview

WHERE segments.date = 'TODAY'

AND metrics.clicks = 15

AND campaign.status = 'ENABLED'

AND adgroup.status = 'ENABLED'

ORDER BY metrics.clicks DESC

By filtering for metrics.clicks = 15, we immediately eliminate low-volume search term noise that would otherwise skew conversion percentages and trigger false alarms.

---

Statistical Framework: Distinguishing Normal Variance from a True Collapse

Detecting conversion anomalies requires a clear statistical threshold. A search term that typically converts at 10% can easily experience zero conversions over 10 consecutive clicks without any systemic technical failure. If your script fires an alert on every 10-click dry spell, alert fatigue will quickly render the automation useless.

Normal Variance vs. True Conversion Collapse

Standard Baseline: [100 Clicks] --- 10 Conversions (10.0% CVR)

Normal Dip: [ 15 Clicks] --- 0 Conversions (0.0% CVR) -- Expected Binomial Variance

Severe Anomaly: [ 60 Clicks] --- 0 Conversions (0.0% CVR) -- 99.8% Probability of Failure

Minimum Click Thresholds and Binomial Distribution

Conversion events follow a binomial distribution. Let $p$ equal the historical conversion rate of a search term. The probability $P$ of recording zero conversions over $n$ clicks is given by:

$P(X = 0) = (1 - p)^n$

Consider a top-tier search term with a historical conversion rate of 8% ($p = 0.08$):

• After 15 clicks with 0 conversions: $(1 - 0.08)^{15} = 0.286$ (28.6% probability). This is normal intraday fluctuation.

• After 35 clicks with 0 conversions: $(1 - 0.08)^{35} = 0.054$ (5.4% probability). Borderline anomaly.

• After 60 clicks with 0 conversions: $(1 - 0.08)^{60} = 0.006$ (0.6% probability). Severe anomaly; 99.4% likelihood that something is broken.

Establishing Dynamic Baseline Rules

Rather than applying a flat rule across all search terms, an enterprise-grade alert script calculates each search term's historical baseline over the preceding 30 days and compares it to today's intraday data.

| Historical Search Term CVR | Minimum Intraday Clicks | Intraday CVR Alert Trigger | Alert Priority |

| :--- | :--- | :--- | :--- |

| 12.0% | $\ge 20$ clicks | $0.0\%$ conversions | CRITICAL (P1) |

| 6.0% - 12.0% | $\ge 35$ clicks |

lt; 1.0\%$ conversions | HIGH (P2) |

| 3.0% - 5.9% | $\ge 50$ clicks |

lt; 0.5\%$ conversions | MEDIUM (P3) |

| < 3.0% | $\ge 80$ clicks | $0.0\%$ conversions | ELEVATED (P4) |

By enforcing minimum click requirements proportional to baseline conversion rates, your script eliminates false positives while instantly detecting true performance crashes.

---

Complete GAQL Script: Detection and Webhook Dispatcher

Below is the complete, production-ready Google Ads Script. It queries historical performance over the last 30 days (LAST30DAYS) to build a baseline conversion profile for high-volume queries, analyzes today's performance (TODAY), flags sudden intraday conversion collapses, and issues an immediate JSON payload to a webhook URL (compatible with Slack, Zapier, Make, or custom API endpoints).

javascript

/

• Google Ads Script: Intraday Search Term Conversion Collapse Alert

• Monitors high-velocity search queries and triggers webhook alerts

• when conversion rates fall below acceptable statistical tolerances.

/

const CONFIG = {

WEBHOOKURL: 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL',

MINHISTORICALCLICKS: 50,

MININTRADAYCLICKS: 25,

DROPPERCENTAGETHRESHOLD: 0.70, // Triggers if CVR drops by 70% or more

ACCOUNTLABEL: 'Production E-Commerce US',

CURRENCYSYMBOL: '

};

function main() {

const baselines = fetchHistoricalBaselines();

const anomalies = evaluateIntradayPerformance(baselines);

if (anomalies.length 0) {

Logger.log('Detected ' + anomalies.length + ' search term anomalies. Dispatching webhook...');

sendWebhookAlert(anomalies);

} else {

Logger.log('Intraday conversion stability confirmed. No alerts triggered.');

}

}

function fetchHistoricalBaselines() {

const historicalMap = new Map();

const query =

SELECT

searchtermview.searchterm,

metrics.clicks,

metrics.conversions

FROM searchtermview

WHERE segments.date DURING LAST30DAYS

AND metrics.clicks = ${CONFIG.MINHISTORICALCLICKS}

;

const search = AdsApp.search(query);

while (search.hasNext()) {

const row = search.next();

const term = row.searchTermView.searchTerm.toLowerCase();

const clicks = parseInt(row.metrics.clicks, 10);

const conversions = parseFloat(row.metrics.conversions);

if (historicalMap.has(term)) {

const existing = historicalMap.get(term);

existing.clicks += clicks;

existing.conversions += conversions;

} else {

historicalMap.set(term, { clicks: clicks, conversions: conversions });

}

}

// Calculate baseline rates

historicalMap.forEach((val, key) = {

val.cvr = val.clicks 0 ? (val.conversions / val.clicks) : 0;

});

return historicalMap;

}

function evaluateIntradayPerformance(baselines) {

const anomalies = [];

const query =

SELECT

campaign.id,

campaign.name,

adgroup.id,

adgroup.name,

searchtermview.searchterm,

metrics.clicks,

metrics.conversions,

metrics.costmicros

FROM searchtermview

WHERE segments.date = 'TODAY'

AND metrics.clicks = ${CONFIG.MININTRADAYCLICKS}

AND campaign.status = 'ENABLED'

AND adgroup.status = 'ENABLED'

;

const search = AdsApp.search(query);

while (search.hasNext()) {

const row = search.next();

const term = row.searchTermView.searchTerm.toLowerCase();

const intradayClicks = parseInt(row.metrics.clicks, 10);

const intradayConversions = parseFloat(row.metrics.conversions);

const intradayCost = parseFloat(row.metrics.costMicros) / 1000000;

const intradayCvr = intradayClicks 0 ? (intradayConversions / intradayClicks) : 0;

if (baselines.has(term)) {

const baseline = baselines.get(term);

// Ensure baseline had meaningful conversion history (3% baseline CVR)

if (baseline.cvr = 0.03) {

const expectedConversions = intradayClicks baseline.cvr;

const dropRate = (baseline.cvr - intradayCvr) / baseline.cvr;

if (dropRate = CONFIG.DROPPERCENTAGETHRESHOLD) {

anomalies.push({

term: term,

campaign: row.campaign.name,

adGroup: row.adGroup.name,

clicks: intradayClicks,

conversions: intradayConversions,

expectedConversions: expectedConversions.toFixed(1),

cost: intradayCost.toFixed(2),

baselineCvr: (baseline.cvr 100).toFixed(2) + '%',

intradayCvr: (intradayCvr 100).toFixed(2) + '%'

});

}

}

}

}

return anomalies;

}

function sendWebhookAlert(anomalies) {

const payload = {

account: CONFIG.ACCOUNTLABEL,

timestamp: new Date().toISOString(),

anomalyCount: anomalies.length,

alerts: anomalies

};

const options = {

method: 'post',

contentType: 'application/json',

payload: JSON.stringify(payload),

muteHttpExceptions: true

};

try {

const response = UrlFetchApp.fetch(CONFIG.WEBHOOKURL, options);

Logger.log('Webhook dispatched. Response code: ' + response.getResponseCode());

} catch (e) {

Logger.log('Webhook dispatch failed: ' + e.toString());

}

}

---

Step-by-Step Installation and Hourly Execution Setup

Installing this script requires administrative access to your Google Ads account. To deploy the script and schedule hourly runs, follow these steps:

Step 1: Open Google Ads Scripts

1. Sign in to your Google Ads account.

2. In the top navigation bar, click Tools and Settings (or the Admin/Tools icon in the updated interface).

3. Under Bulk Actions, select Scripts.

Step 2: Create and Authorize the Script

1. Click the blue + button to create a new script.

2. Replace the placeholder code with the script provided above.

3. Update the CONFIG object with your actual Slack/Discord/Make webhook URL and your internal account label.

4. Click Authorize at the bottom right. When prompted, log in with your Google account and grant permissions for Google Ads API access and UrlFetchApp execution.

Step 3: Run a Preview Test

1. Click the Preview button at the bottom of the editor.

2. Check the Logs console. Confirm that the script extracts historical baselines without syntax errors. If your account has not recorded high-volume search terms today, the log will output: Intraday conversion stability confirmed. No alerts triggered.

Step 4: Schedule Hourly Frequency

1. Click Save.

2. Return to the Scripts dashboard.

3. Locate your newly created script in the list and find the Frequency column.

4. Change the execution schedule to Hourly.

Execution Timeline:

[09:00 AM] Script runs - Checks Today vs. 30-Day Base - Normal

[10:00 AM] Checkout Gateway Fails

[10:15 AM] Search Term 'buy waterproof hiking boots' logs 32 clicks, 0 conversions

[11:00 AM] Script runs - DropRate = 100% - Webhook Triggered - Slack Alert Received

If you want comprehensive account monitoring without building and maintaining custom JavaScript automations, check out our PPC management software for built-in, out-of-the-box anomaly detection.

---

Root Cause Diagnostics: What to Check When an Alert Fires

When a search terms conversion drop script webhook fires an alert, treat it like an urgent operational incident. Do not immediately pause campaigns or adjust bids without identifying the underlying cause. Run through this systematic triage protocol:

ALERT RECEIVED: Intraday Conversion Collapse

│

┌───────────┴───────────┐

▼ ▼

[Technical Failure], [Traffic Disruption]

│ │

├─ Landing Page 500? ├─ New Search Intent?

├─ Tag Firing via GTM? ├─ Match Type Expansion?

└─ Checkout Broken? └─ Device Outlier (e.g. iOS)?

1. Site Infrastructure and Server Uptime

Visit the destination landing page associated with the affected search term in an incognito window. Open Developer Tools (F12) and inspect the Network tab:

• Does the landing page return a 200 OK status, or are you seeing 500 Internal Server Error, 502 Bad Gateway, or 504 Gateway Timeout?

• Did a recent code deployment break mobile layout responsiveness?

2. Google Tag Manager and Conversion Pixel Execution

Use Google Tag Assistant to verify that conversion tracking tags fire on the appropriate post-purchase or thank-you page triggers:

• Has a consent banner update inadvertently blocked Google Ads conversion tags across specific browsers (e.g., Safari ITP or Chrome updates)?

• Was an enhanced conversion variable recently altered in your data layer, preventing transaction validation?

For a structured troubleshooting framework covering conversion tracking and tag integrity, review our guide on Google Ads not working.

3. Payment Gateways and Form API Validations

Submit a live test transaction. E-commerce stores often experience silent conversion drops when Stripe, PayPal, or Shopify checkout APIs hit rate limits or reject API keys following plugin updates. Lead-generation sites frequently suffer from silent webhook failures where forms display a loading spinner without registering completions.

4. Search Intent and Broad Match Spikes

Examine the exact search query that triggered the alert. If your keyword matched to an irrelevant query variation via broad match expansion, conversion rates will naturally drop. For practical strategies on finding and neutralizing broad match waste, read our walkthrough on how to use the Google Ads search terms report to cut wasted spend and check our guide on how to find negative keywords in Google Ads.

---

Advanced Enhancements: Automated Safeguards and Webhook Payloads

Once your basic alert system is functional, you can expand its capabilities with automated safeguards and detailed webhook payloads.

Pushing Rich Slack Payloads

To make alerts immediately actionable for media buyers, format your webhook payload using Slack Block Kit or Teams Adaptive Cards. Here is an example of formatting a rich JSON payload within Google Apps Script:

javascript

function buildSlackBlockPayload(anomaly) {

return {

blocks: [

{

type: 'header',

text: {

type: 'plaintext',

text: '🚨 CRITICAL: Conversion Rate Collapse Detected',

emoji: true

}

},

{

type: 'section',

fields: [

{ type: 'mrkdwn', text: 'Search Term:\n' + anomaly.term },

{ type: 'mrkdwn', text: 'Campaign:\n' + anomaly.campaign },

{ type: 'mrkdwn', text: 'Intraday Clicks:\n' + anomaly.clicks },

{ type: 'mrkdwn', text: 'Intraday Spend:\n' + CONFIG.CURRENCYSYMBOL + anomaly.cost },

{ type: 'mrkdwn', text: 'Historical CVR:\n' + anomaly.baselineCvr },

{ type: 'mrkdwn', text: 'Intraday CVR:\n' + anomaly.intradayCvr }

]

},

{

type: 'context',

elements: [

{

type: 'mrkdwn',

text: 'Expected Conversions: ~' + anomaly.expectedConversions + ' | Immediate landing page verification recommended.'

}

]

}

]

};

}

Automated Bid Throttling vs. Passive Alerting

Should your script automatically pause ad groups or apply negative keywords when an anomaly is detected?

Automated bid or status changes carry risks. If an alert fires because of a 45-minute delay in third-party tag reporting, pausing your top-performing search term can cost your business thousands in lost sales while the algorithm restarts learning phases. A safer safeguard is automated target CPA padding or sending a high-priority alert to an on-call engineer, rather than executing destructive write operations on primary campaigns.

If you prefer intelligent, automated account management that handles tracking anomalies, bid adjustments, and campaign stability without brittle custom scripts, consider exploring AdTurbo. At $149/mo (backed by a 7-day trial; credit card required), AdTurbo continuously protects your budget by pairing automated tracking monitors with machine learning optimization.

---

Related Guides

• How to Use the Google Ads Search Terms Report to Cut Wasted Spend

• Google Ads Not Working? 11 Things to Check Before You Panic

• How to Find Negative Keywords in Google Ads (Step by Step)

---

Frequently Asked Questions

Can this GAQL script automatically pause underperforming search terms?

Yes, you can modify the script to add an exact negative keyword using AdGroup.createNegativeKeyword() when an anomaly occurs. However, automatic pausing is generally not recommended because reporting delays or transient server glitches can cause false positives that disrupt your campaign's algorithmic learning.

How does conversion lag affect intraday alert accuracy?

Conversion lag occurs when users click an ad during morning hours but do not complete their purchase until the evening, making intraday conversion rates appear artificially low. You can prevent false positives by setting higher minimum click thresholds (such as 30 to 50 clicks) and configuring alerts to trigger only when conversion drops exceed 70% to 80% of historical baselines.

Does Google Ads Scripts support real-time data streaming?

Google Ads Scripts do not support sub-minute real-time webhooks, but they can run on an hourly schedule using the native scheduler. Most API metric tables—including the searchtermview—update throughout the day with latencies typically ranging between 15 and 90 minutes, making hourly script execution the industry standard for fast anomaly detection.

What permissions are needed to run GAQL search term scripts?

To run the script, your Google user account must have Standard or Administrative access to the Google Ads account or Manager Account (MCC). During initial installation, you will also need to grant OAuth permissions inside Google Ads so the script can execute search queries and send external HTTP POST requests via UrlFetchApp.

Google Verified Fully Automated

Get More Leads & Sales From Google Ads — On Autopilot

AdTurbo is your AI Google Ads agent, built by top Google Ads agency owners. AdTurbo works tirelessly in the background managing your Google Ads to get more leads and sales, while you focus on running your business.

Sign up with Google

7-day free trial. No contracts. Cancel anytime.