GAQL Script: Pause Exact Match Keywords at 3x Target CPA
Learn how to build a Google Ads GAQL script to auto-pause exact match keywords exceeding 3x your target CPA. Complete code, logic, and safety guardrails.
By AdTurbo Team · 2026-11-30
Exact match keywords were once considered the safest bet in Google Ads. Media buyers treated them as guaranteed conversion drivers that rarely went rogue. However, with modern close variant matching, shifts in search behavior, and algorithmic auction volatility, even tightly configured exact match queries can burn through budget without hitting target efficiency.
When an exact match keyword climbs past two or three times your acceptable cost per acquisition (CPA), manual management often catches the bleed too late. Implementing an automated safeguard using Google Ads Query Language (GAQL) inside Google Ads Scripts lets you systematically monitor and pause exact match search keywords exceeding target CPA thresholds before your budget collapses.
Here is a comprehensive technical breakdown of how to build, deploy, and safeguard a production-grade GAQL script to pause runaway exact match keywords at 3x your target CPA.
---
Why Exact Match Keywords Still Blow Past Target CPA
Many advertisers assume smart bidding or tight match types eliminate wasted spend. In reality, exact match keywords can silently drain thousands of dollars if left unchecked.
The Erosion of Strict Matching
Over the past few years, Google has expanded exact match syntax ([keyword]) to incorporate close variants, implied words, intent synonyms, and reordered phrasing. An exact match keyword for [commercial roofing repair] might trigger queries for residential services or emergency consultation queries that convert at a drastically lower rate. If you do not monitor your queries alongside a solid search terms report guide, your perceived "safe" match type quickly incurs high CPAs.
The Problem of Budget Fragmentation
When accounts accumulate dozens of exact match keywords that each generate 10 to 20 clicks a week, spend fragments across the entire ad group. No single keyword gathers statistically conclusive conversion data within a two-day window, masking the fact that five of those keywords combined spent $1,500 for zero conversions over a 30-day window. This silent accumulation of spend drags down the entire account's portfolio efficiency.
Hidden 'Zombie' Keywords
Zombie keywords are terms that sit in an account consuming small amounts of spend every month without ever converting. Over a quarter, a single zombie keyword might spend $450 with zero sales. Multiply that across 40 exact match ad groups, and you have $18,000 in unrecoverable ad spend. Automating a cut-off threshold eliminates the human error of missing these slow leaks during routine weekly reviews.
---
The Mathematical Basis for the 3x Target CPA Threshold
Why pause at 3x target CPA instead of 1.5x or 2x? Setting your script's cutoff too tight damages your campaigns, while setting it too loose wastes capital.
+-----------------------+---------------------+---------------------------------------------------------+
| Multiplier Threshold | Risk of Type I Error| Recommended Use Case |
| (Multiple of Target) | (Premature Pause) | |
+-----------------------+---------------------+---------------------------------------------------------+
| 1.5x Target CPA | Very High (35-45%) | High-volume lead gen with short conversion windows |
| 2.0x Target CPA | Moderate (15-25%) | Standard accounts with stable 24-48h attribution cycles |
| 3.0x Target CPA | Low (2-5%) | Recommended default; catches statistically failed terms |
| 4.0x+ Target CPA | Near Zero (<1%) | Too forgiving; results in significant budget leakage |
+-----------------------+---------------------+---------------------------------------------------------+
The Law of Small Numbers
In statistical analysis, small sample sizes produce erratic variations. If your target CPA is $50, an exact match keyword that spends $75 without a conversion has an apparent CPA of infinity. Pausing that keyword at 1.5x target ($75) commits a Type I error (false positive): the keyword may very well convert on click number 12 and settle into a $35 CPA over a 50-click sample.
By waiting until a keyword spends 3x your target CPA (e.g., $150 with zero conversions, or $300 with one conversion against a $50 target), the probability that the poor performance is purely random noise drops below 5%. At 3x target CPA, you have strong statistical confidence that the keyword's conversion rate or auction CPC cannot support your economics.
Conversion Lag and Attribution Windows
Another critical factor is conversion lag. If your sales cycle spans 7 to 14 days, conversions originating from clicks today may not appear in the interface until next week. If a script executes against last week's data without accounting for attribution delays, it will prematurely pause keywords that actually drove profitable pipeline. A 3x threshold provides an adequate buffer against latency while catching true outliers.
---
Understanding GAQL and Modern Google Ads Scripts
Modern Google Ads scripts run on the new script engine powered by the Google Ads API and Google Ads Query Language (GAQL). Older scripts relied on the deprecated AWQL (AdWords Query Language) and legacy AdsApp iterators, which suffered from severe pagination limits and slow execution speeds.
Anatomy of a GAQL Keyword Query
GAQL queries resemble standard SQL statements, targeting specific API resources, metrics, and segments. For keyword management, the primary resource is keywordview, joined with attributes from adgroupcriterion.
Here is how GAQL structures keyword extraction:
sql
SELECT
adgroupcriterion.criterionid,
adgroupcriterion.keyword.text,
adgroupcriterion.keyword.matchtype,
adgroupcriterion.status,
metrics.costmicros,
metrics.conversions,
campaign.id,
campaign.name,
adgroup.id
FROM keywordview
WHERE
adgroupcriterion.keyword.matchtype = 'EXACT'
AND adgroupcriterion.status = 'ENABLED'
AND campaign.status = 'ENABLED'
AND segments.date DURING LAST30DAYS
Notice that currency values in GAQL are returned in micros. One unit of your account currency equals 1,000,000 micros. Therefore, a spend of $150 equals 150,000,000 micros. Handling this math accurately inside your JavaScript logic is essential to prevent unintended changes to your account.
---
Building the GAQL Script: Complete Step-by-Step Code
Below is the production-ready script designed to identify and pause exact match search keywords exceeding 3x your defined target CPA. It features safety guardrails, including maximum change limits, account labeling, and email logging.
The Full JavaScript Implementation
javascript
/
• Google Ads Script: Auto-Pause High CPA Exact Match Keywords (GAQL)
• AdTurbo Automation Framework
/
const CONFIG = {
TARGETCPA: 45.00, // Your base target CPA in account currency
CPAMULTIPLIER: 3.0, // Pause threshold multiplier (3.0 = 3x Target CPA)
MINCLICKS: 15, // Minimum clicks before evaluating conversion rate
DATERANGE: 'LAST30DAYS', // Lookback window: LAST30DAYS, LAST14DAYS
LABELNAME: 'ScriptPaused3xCPA', // Label applied to paused entities
DRYRUN: true, // Set to FALSE to apply real changes
MAXPAUSESPERRUN: 25, // Circuit breaker: max keywords to pause in one execution
NOTIFICATIONEMAIL: '[email protected]' // Alerts recipient
};
function main() {
const pauseThresholdCpa = CONFIG.TARGETCPA CONFIG.CPAMULTIPLIER;
Logger.log(Starting run. Target CPA: ${CONFIG.TARGETCPA} | Cutoff: ${pauseThresholdCpa} | Dry Run: ${CONFIG.DRYRUN});
ensureLabelExists(CONFIG.LABELNAME);
// Construct the GAQL query
const query =
SELECT
adgroupcriterion.criterionid,
adgroupcriterion.keyword.text,
adgroupcriterion.keyword.matchtype,
adgroupcriterion.status,
adgroup.id,
adgroup.name,
campaign.id,
campaign.name,
metrics.costmicros,
metrics.conversions,
metrics.clicks
FROM keywordview
WHERE
adgroupcriterion.keyword.matchtype = 'EXACT'
AND adgroupcriterion.status = 'ENABLED'
AND campaign.status = 'ENABLED'
AND adgroup.status = 'ENABLED'
AND metrics.clicks = ${CONFIG.MINCLICKS}
AND segments.date DURING ${CONFIG.DATERANGE}
;
const searchResults = AdsApp.search(query);
const keywordsToPause = [];
while (searchResults.hasNext()) {
const row = searchResults.next();
const cost = parseFloat(row.metrics.costMicros) / 1000000;
const conversions = parseFloat(row.metrics.conversions);
const clicks = parseInt(row.metrics.clicks, 10);
const keywordText = row.adGroupCriterion.keyword.text;
const campaignName = row.campaign.name;
const adGroupName = row.adGroup.name;
// Calculate effective CPA (zero conversions treated as cost / 1 for threshold breach checking)
let calculatedCpa = 0;
let isBreaching = false;
if (conversions === 0) {
if (cost = pauseThresholdCpa) {
calculatedCpa = cost; // Total spend with zero return
isBreaching = true;
}
} else {
calculatedCpa = cost / conversions;
if (calculatedCpa = pauseThresholdCpa) {
isBreaching = true;
}
}
if (isBreaching) {
keywordsToPause.push({
campaignId: row.campaign.id,
adGroupId: row.adGroup.id,
criterionId: row.adGroupCriterion.criterionId,
keywordText: keywordText,
campaignName: campaignName,
adGroupName: adGroupName,
cost: cost.toFixed(2),
conversions: conversions,
clicks: clicks,
cpa: calculatedCpa.toFixed(2)
});
}
}
Logger.log(Found ${keywordsToPause.length} exact match keywords violating 3x CPA threshold.);
// Enforce circuit breaker
const executionBatch = keywordsToPause.slice(0, CONFIG.MAXPAUSESPERRUN);
if (keywordsToPause.length CONFIG.MAXPAUSESPERRUN) {
Logger.warn(Warning: Found ${keywordsToPause.length} violating keywords. Circuit breaker restricted execution to ${CONFIG.MAXPAUSESPERRUN}.);
}
const reportRows = [];
for (const item of executionBatch) {
Logger.log(Target: [${item.keywordText}] in Campaign: "${item.campaignName}" | Spend: ${item.cost} | Conv: ${item.conversions} | CPA: ${item.cpa});
if (!CONFIG.DRYRUN) {
pauseKeyword(item.campaignId, item.adGroupId, item.criterionId, CONFIG.LABELNAME);
}
reportRows.push([${item.keywordText}] | Campaign: ${item.campaignName} | Spend: ${item.cost} | Conv: ${item.conversions} | Actual CPA: ${item.cpa});
}
if (reportRows.length 0 && CONFIG.NOTIFICATIONEMAIL) {
sendSummaryEmail(reportRows, CONFIG.DRYRUN);
}
}
function pauseKeyword(campaignId, adGroupId, criterionId, labelName) {
const keywordIterator = AdsApp.keywords()
.withIds([[campaignId, adGroupId, criterionId]])
.get();
if (keywordIterator.hasNext()) {
const kw = keywordIterator.next();
kw.pause();
kw.applyLabel(labelName);
}
}
function ensureLabelExists(labelName) {
const labelIterator = AdsApp.labels().withCondition(name = '${labelName}').get();
if (!labelIterator.hasNext()) {
AdsApp.createLabel(labelName, 'Automatically paused by GAQL threshold script', 'FF5722');
}
}
function sendSummaryEmail(reportRows, isDryRun) {
const subject = Google Ads Alert: ${reportRows.length} Keywords Paused (3x CPA Script)${isDryRun ? ' [DRY RUN]' : ''};
const body = The automated GAQL script evaluated your search keywords.\n\n +
Status: ${isDryRun ? 'DRY RUN (No changes made)' : 'LIVE CHANGES APPLIED'}\n\n +
Flagged Keywords:\n +
reportRows.join('\n') +
\n\nCheck account logs for full details.;
MailApp.sendEmail(CONFIG.NOTIFICATIONEMAIL, subject, body);
}
---
Critical Guardrails: Preventing Script Disasters
Automating keyword changes directly in an active ad account carries inherent risks. A syntax error, missing metric check, or currency decimal error can wipe out high-performing campaigns in seconds. Always adhere to these structural guardrails when deploying automated bid or status changes.
1. The Circuit Breaker (Cap Maximum Pauses)
Notice the CONFIG.MAXPAUSESPERRUN variable set to 25. Never allow a script to execute unlimited destructive updates across an entire account. If an API reporting glitch causes conversion tracking to temporarily report zero conversions for 24 hours, an unconstrained script would interpret every active keyword as a zero-conversion failure and pause your entire account. A circuit breaker caps potential collateral damage.
2. Mandatory Dry Run Mode
Always test custom scripts with CONFIG.DRYRUN = true for at least two consecutive scheduled runs. Inspect the Execution Log in the Google Ads Scripts interface. Review the logged keywords, their observed spend, and their calculated CPA. Only set DRYRUN to false when you confirm that the extracted metrics align with your manual review in the Google Ads UI.
3. Clear Entity Labeling
The script applies a designated label (ScriptPaused3xCPA) to every paused keyword. This guarantees auditability. If you need to re-enable terms after an attribution adjustment or seasonal change, you can easily filter for that label in the Google Ads interface and bulk-enable them. If you suspect your account is hemorrhaging money beyond high-CPA keywords, run through our PPC audit checklist to verify your structure, match types, and bid parameters.
---
When to Pause Exact Match vs. Relying on Broad Match
Killing an exact match keyword that exceeds 3x target CPA raises a critical architectural question: what should you do with that traffic going forward? Should you delete the keyword, rework your ad group, or rely on broad match with Smart Bidding?
+------------------------------------------------+-----------------------------+----------------------------------------------+
| Scenario | Exact Match Performance | Recommended Strategic Action |
+------------------------------------------------+-----------------------------+----------------------------------------------+
| Query volume is stable, CPA 3x target | Consistently unprofitable | Pause exact; add negative keyword if intent |
| | | is fundamentally unqualified |
| High impression volume, low CTR, zero conv | Poor relevance / wrong copy | Pause exact; rewrite ad copy & landing page |
| Query has high historical value but spikes | Volatile auction / seasonality| Keep exact paused; let portfolio Target CPA |
| intermittently above 3x | | absorb intent via broad match buffer |
| Keyword triggers irrelevant close variants | Variant mismatch | Add exact negative for variant, retain root |
+------------------------------------------------+-----------------------------+----------------------------------------------+
What the Data Doesn't Show
When an exact match keyword exceeds 3x target CPA, standard metrics do not reveal why the failure occurred. Did the conversion rate crater because of a landing page issue? Did a surge in aggressive competitor bidding inflate CPCs? Or did close variant expansion dilute query intent?
Before abandoning a core term entirely, check the search terms report for that specific criterion. If 60% of the cost came from a single low-intent close variant, you do not need to discard the root concept. Simply add that specific rogue query as a negative exact match keyword and test the primary keyword again. If you are struggling with keyword curation, review our breakdown of how to find negative keywords to refine your traffic flow.
Shifting Volume to Broad Match Under Portfolio Bidding
Google's modern recommendation is to transition paused exact terms into broad match keywords managed by Target CPA or Target ROAS bidding. Does this make sense when an exact match keyword just failed at 3x target CPA?
It depends on auction context:
• If the keyword represents non-converting user intent: Do not switch it to broad match. If an exact match failed to convert at 3x CPA, opening the floodgates to broad match variations of the same intent will only accelerate wasted spend.
• If the keyword failed due to high standalone manual CPCs: Broad match under Smart Bidding might find cheaper alternative entry auctions for that same intent that manual or unconstrained exact match bidding missed.
If manual script maintenance and custom coding feel burdensome, modern solutions can handle this automatically. Teams wanting programmatic bid, keyword, and budget governance without managing custom JavaScript can leverage an intelligent Google Ads automation tool like AdTurbo ($149/mo with a 7-day trial) to monitor performance thresholds continuously and cut unviable search traffic automatically.
---
Deploying and Scheduling the Script in Google Ads
To put your GAQL keyword pruning script into action, follow these operational deployment steps:
Step 1: Open the Script Editor
1. Sign in to your Google Ads account.
2. In the top navigation menu, click Tools and settings (or the Admin/Tools icon in the updated interface).
3. Under Bulk Actions, select Scripts.
4. Click the blue + button to create a new script.
Step 2: Paste and Authorize
1. Clear the default placeholder function in the editor.
2. Paste the full script code provided above.
3. Update the CONFIG values at the top of the file to match your account economics (Target CPA, minimum clicks, notification email).
4. Click Authorize at the bottom right to grant the script permission to manage ads and send email alerts on your behalf.
Step 3: Run a Preview Test
1. Ensure DRYRUN: true is set in the configuration block.
2. Click Preview.
3. Inspect the Logs tab at the bottom of the window. Verify that the script targets the exact match keywords you expect without surfacing false positives.
4. Change DRYRUN to false and click Save.
Step 4: Configure the Automation Schedule
1. Return to the main Scripts dashboard.
2. Locate your newly created script in the list.
3. Under the Frequency column, choose your run cadence. For a 30-day lookback window checking a 3x CPA threshold, running the script Weekly (e.g., every Monday at 3:00 AM) is optimal. Running it hourly or daily is unnecessary and increases the risk of pausing keywords before attribution models settle.
If you find your campaign performance deteriorating despite tight keyword rules, review our diagnostic guide on Google Ads not working to pinpoint systemic tracking or configuration errors.
---
Advanced Script Customization: Variable Multipliers by Campaign
In larger accounts, a single static Target CPA applied across every campaign causes issues. Brand campaigns, high-margin product lines, and competitive discovery funnels all operate with different margin profiles.
To adapt the script for multi-campaign architectures, you can replace the flat CONFIG.TARGETCPA scalar with a dynamic campaign-lookup dictionary or pull the target directly from Google Ads campaign bidding settings:
javascript
// Dynamic Target CPA extraction via GAQL
const dynamicQuery =
SELECT
campaign.id,
campaign.name,
campaign.targetcpa.targetcpamicros,
adgroupcriterion.keyword.text,
metrics.costmicros,
metrics.conversions
FROM keywordview
WHERE
adgroupcriterion.keyword.matchtype = 'EXACT'
AND adgroupcriterion.status = 'ENABLED'
AND campaign.biddingstrategytype = 'TARGETCPA'
AND segments.date DURING LAST30DAYS
;
By reading the campaign's native targetcpamicros setting directly from the API, your script dynamically calculates the 3x threshold on a per-campaign basis. When your marketing team adjusts campaign target CPAs in the UI, the script automatically recalibrates its pause criteria without requiring code updates.
Automating keyword pruning via GAQL frees your media buyers from repetitive manual checks, prevents runaway spend, and guarantees your exact match portfolio operates within strict efficiency boundaries.
---
Related Guides
• How to Use the Google Ads Search Terms Report to Cut Wasted Spend
• How to Find Negative Keywords in Google Ads (Step by Step)
• Google Ads Optimization Checklist: 15 Things to Check Every Week
---
Frequently Asked Questions
What is a CPA on Google Ads?
Cost per acquisition (CPA) is an advertising metric that measures the total cost incurred to generate a single conversion, such as a lead or purchase. It is calculated by dividing total advertising spend by the number of tracked conversions over a given timeframe. Maintaining a sustainable CPA ensures your advertising investments remain profitable.
What should my target CPA be?
Your target CPA should be derived directly from your unit economics, profit margins, and customer lifetime value (LTV). For lead generation, calculate your average deal size multiplied by your lead-to-close rate and target profit margin to find your ceiling. In e-commerce, target CPA typically mirrors your average order value minus product costs and target margins.
What does an optimization score of 75 mean?
An optimization score of 75 means Google Ads estimates your account is applying roughly 75% of its algorithmic best-practice recommendations. It does not measure your actual return on ad spend or bottom-line business profitability. Advertisers should evaluate recommendations individually rather than automatically accepting them to achieve a 100% score.
What is the average CPA for Google Ads?
Across all industries, the average CPA in Google Ads typically ranges between $40 and $80 for search campaigns, though it varies wildly by vertical. Highly competitive legal and financial sectors frequently see CPAs exceeding $150 to $300, while low-friction e-commerce categories can achieve CPAs under $25.