Script to Auto-Pause High CPA Broad Match Keywords

Deploy a custom Google Ads script to auto-pause runaway broad match keywords when CPA explodes. Complete code, safety checks, and step-by-step setup.

By AdTurbo Team · 2026-12-02

Broad match keywords combined with Google Ads Smart Bidding can unlock scale, but they also introduce severe downside risk. When Google's contextual expansion algorithm tests new semantic clusters, a single query variant can consume hundreds or thousands of dollars in hours without generating a conversion.

By the time a human media buyer reviews account metrics on Monday morning, the damage is already done: target CPA has doubled, blended ROI has plummeted, and budget that should have driven qualified leads was consumed by broad intent search terms.

Standard automated rules and native bidding controls often fail to prevent this because they rely on fixed lookback windows or delayed conversion attribution. To safeguard your campaigns, you need a custom script to auto-pause high CPA broad match keywords dynamically before budget bleeds out.

Here is how broad match runaway spend happens, the production-ready script code to control it, and how to implement real-time guardrails inside your account.

---

The Mechanics of Broad Match CPA Explosions

Google pushes broad match as the ideal companion to Target CPA (tCPA) and Maximize Conversions bidding. In theory, broad match provides signals, and machine learning bids down on irrelevant queries while bidding up on high-converting intents. In practice, search queries do not always behave predictably.

Why Broad Match Runs Away Under Smart Bidding

1. Sudden Semantic Drift: Google expands broad match based on user history, recent searches, and landing page content. If an external event, viral trend, or algorithmic update triggers a loose association between your keyword and an unrelated high-volume search trend, your keyword enters auctions you never intended to enter.

2. Aggressive Exploration Phases: When you raise a campaign budget or launch new ad copy, Smart Bidding often tests new search inventory. If your target CPA is $60, the bidding engine may spend 3x to 5x that target on an untested query cluster before determining the traffic does not convert.

3. Conversion Lag Blindspots: Smart Bidding adjusts bids assuming a normal conversion lag distribution. If a broad match keyword triggers clicks that have a 7-day conversion lag, the algorithm continues bidding aggressively during days 1 to 3 because it assumes conversions will materialize later. If those clicks were low-intent junk, that spend is lost.

Broad Match vs. Exact Match Risk Profiles

| Attribute | Exact Match | Phrase Match | Broad Match |

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

| Query Drift Risk | Very Low | Moderate | High to Extreme |

| Intraday Spend Volatility | Controlled by search volume | Moderately predictable | Uncapped expansion potential |

| Automated Rule Suitability | Native rules work well | Native rules work well | Requires programmatic micro-checks |

| CPA Blowout Velocity | Low | Medium | High (can burn 50%+ daily budget) |

| Need for Script Safeguards | Minimal | Optional | Essential |

When managing complex accounts, using a dedicated ppc-management-software platform or programmatic script safeguards prevents this runaway behavior without forcing you to abandon broad match entirely.

---

Why Native Google Ads Rules Fall Short

Many advertisers attempt to solve this problem with native Google Ads automated rules. While automated rules are useful for scheduling and basic tasks, they lack the computational precision required to police broad match keywords dynamically.

1. Inflexible Lookback Windows

Google Ads automated rules force you to evaluate metrics across static date ranges: "Today", "Yesterday", "Last 7 Days", or "Last 14 Days". However, broad match volatility occurs across fluid timelines. A keyword might have performed efficiently over the last 30 days, masking the fact that it spent $400 today with zero conversions. An automated rule looking at the "Last 30 Days" will not catch the spike because the historical conversion volume averages out the current disaster.

2. Failure to Handle Attribution Lag

If an automated rule checks "Last 7 Days" and pauses any keyword with a CPA above $100, it may pause your highest-performing broad match terms simply because conversions from the last 48 hours have not yet finished reporting. Native rules do not let you exclude the most recent 24-48 hours while simultaneously checking intraday spend thresholds.

3. Lack of Match-Type Filtering Logic

Native rules struggle with granular conditional logic. You typically do not want to pause an exact match keyword that hits a temporary CPA spike because its intent is verified and conversions often backfill. You do want to aggressively pause broad match keywords exhibiting sudden spikes. Setting this up across hundreds of ad groups via native rules requires dozens of separate, fragile rules that clutter your interface.

---

Architecture of an Auto-Pause Runaway CPA Script

To build an effective pause broad match runaway cpa script, the script must evaluate data using a two-tier evaluation model rather than a simple single-metric threshold.

[Hourly Execution Trigger]

│

▼

[Select Enabled Broad Match Keywords]

│

▼

[Condition 1: Has Spend Exceeded Minimum Safety Floor?]

├── NO ── Do Nothing (Prevent premature pauses on low data)

└── YES ──

│

▼

[Condition 2: Check Conversion Metrics]

├── Conversions = 0 AND Spend Max Allowed Zero-Conversion Spend ── PAUSE & LABEL

└── Conversions 0 AND (Cost / Conversions) Threshold CPA ── PAUSE & LABEL

│

▼

[Send Email Notification / Log Action]

The Mathematical Logic

The script relies on three dynamic parameters:

1. Target CPA Multiplier ($M$): The allowable multiple of your target CPA before a keyword is deemed runaway (typically 2.0x to 3.0x).

2. Zero-Conversion Spend Ceiling ($Z$): The maximum dollar amount a broad match keyword can spend without generating a single conversion before it is paused (typically 1.5x to 2.5x of target CPA).

3. Statistical Significance Floor ($C{min}$): The minimum click or spend threshold required before the script runs calculations, preventing false positives from a single expensive click.

For accounts requiring continuous optimization without manual script maintenance, deploying an autonomous system like AdTurbo automates bid policing, search term pruning, and budget allocation in real time.

---

The Complete Production Code

Below is the complete, single-file JavaScript code designed for the Google Ads Scripts environment (supporting the modern Google Ads API infrastructure). It targets broad match keywords, evaluates their performance over a defined timeframe, pauses violators, applies a tracking label, and logs the changes.

javascript

/

• Google Ads Script: Auto-Pause Runaway Broad Match Keywords on High CPA

• Description: Identifies broad match keywords that have exceeded target CPA

• thresholds or spent past a zero-conversion ceiling within the evaluation window.

• Pauses offending keywords and applies a label for auditing.

/

const CONFIG = {

// Evaluation settings

TARGETCPA: 45.00, // Your benchmark target CPA in account currency

CPAMULTIPLIERTHRESHOLD: 2.5, // Pause if CPA exceeds (TARGETCPA MULTIPLIER)

ZEROCONVERSIONSPENDMULT: 2.0, // Pause if Spend (TARGETCPA MULT) with 0 conversions

MINSPENDFLOOR: 50.00, // Absolute minimum spend before checking logic

DATERANGE: 'LAST7DAYS', // Evaluation window: 'TODAY', 'YESTERDAY', 'LAST7DAYS', 'LAST14DAYS'

// Safety & labeling

LABELNAME: 'ScriptPausedRunawayCPA',

CAMPAIGNNAMECONTAINS: '', // Optional: Filter for specific campaigns (e.g. 'SearchBroad')

CAMPAIGNNAMEDOESNOTCONTAIN: 'Brand', // Protect brand campaigns from execution

DRYRUN: false, // Set to true to test without making actual changes

// Notifications

SENDEMAIL: true,

NOTIFICATIONEMAIL: '[email protected]'

};

function main() {

checkOrCreateLabel(CONFIG.LABELNAME);

const maxAllowedCpa = CONFIG.TARGETCPA CONFIG.CPAMULTIPLIERTHRESHOLD;

const maxZeroConvSpend = CONFIG.TARGETCPA CONFIG.ZEROCONVERSIONSPENDMULT;

Logger.log('Starting Broad Match CPA Police Script...');

Logger.log('Evaluation Window: ' + CONFIG.DATERANGE);

Logger.log('Max Allowed CPA:

+ maxAllowedCpa.toFixed(2));

Logger.log('Max Zero-Conversion Spend:

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.

+ maxZeroConvSpend.toFixed(2));

let keywordSelector = AdsApp.keywords()

.withCondition('Status = ENABLED')

.withCondition('CampaignStatus = ENABLED')

.withCondition('AdGroupStatus = ENABLED')

.withCondition('KeywordMatchType = BROAD')

.withCondition('Cost ' + CONFIG.MINSPENDFLOOR)

.forDateRange(CONFIG.DATERANGE);

if (CONFIG.CAMPAIGNNAMECONTAINS !== '') {

keywordSelector = keywordSelector.withCondition("CampaignName CONTAINS '" + CONFIG.CAMPAIGNNAMECONTAINS + "'");

}

if (CONFIG.CAMPAIGNNAMEDOESNOTCONTAIN !== '') {

keywordSelector = keywordSelector.withCondition("CampaignName DOESNOTCONTAINIGNORECASE '" + CONFIG.CAMPAIGNNAMEDOESNOTCONTAIN + "'");

}

const keywordIterator = keywordSelector.get();

const pausedKeywords = [];

while (keywordIterator.hasNext()) {

const keyword = keywordIterator.next();

const stats = keyword.getStatsFor(CONFIG.DATERANGE);

const cost = stats.getCost();

const conversions = stats.getConversions();

const currentCpa = conversions 0 ? (cost / conversions) : 0;

let shouldPause = false;

let pauseReason = '';

// Case 1: Spend without conversions exceeds ceiling

if (conversions === 0 && cost = maxZeroConvSpend) {

shouldPause = true;

pauseReason = 'Zero conversions with spend of

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.

+ cost.toFixed(2) + ' (Limit:
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.

+ maxZeroConvSpend.toFixed(2) + ')';

}

// Case 2: CPA exceeds threshold multiplier

else if (conversions 0 && currentCpa = maxAllowedCpa) {

shouldPause = true;

pauseReason = 'CPA of

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.

+ currentCpa.toFixed(2) + ' exceeded max limit of
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.

+ maxAllowedCpa.toFixed(2);

}

if (shouldPause) {

Logger.log('VIOLATION: Keyword: "' + keyword.getText() + '" in Campaign: "' + keyword.getCampaign().getName() + '"');

Logger.log('Reason: ' + pauseReason);

if (!CONFIG.DRYRUN) {

keyword.pause();

keyword.applyLabel(CONFIG.LABELNAME);

} else {

Logger.log('[DRY RUN] Keyword would have been paused.');

}

pausedKeywords.push({

campaign: keyword.getCampaign().getName(),

adGroup: keyword.getAdGroup().getName(),

keyword: keyword.getText(),

cost: cost,

conversions: conversions,

cpa: conversions 0 ? currentCpa.toFixed(2) : 'N/A',

reason: pauseReason

});

}

}

Logger.log('Processed keywords. Total paused: ' + pausedKeywords.length);

if (pausedKeywords.length 0 && CONFIG.SENDEMAIL && !CONFIG.DRYRUN) {

sendSummaryEmail(pausedKeywords);

}

}

function checkOrCreateLabel(labelName) {

const labelIterator = AdsApp.labels().withCondition("Name = '" + labelName + "'").get();

if (!labelIterator.hasNext()) {

AdsApp.createLabel(labelName, 'Keywords paused automatically due to runaway CPA thresholds', 'FF0000');

Logger.log('Created label: ' + labelName);

}

}

function sendSummaryEmail(pausedList) {

let body = 'The Broad Match CPA Guard script paused ' + pausedList.length + ' keyword(s) during its latest run:\n\n';

for (let i = 0; i < pausedList.length; i++) {

const item = pausedList[i];

body += 'Campaign: ' + item.campaign + '\n';

body += 'Ad Group: ' + item.adGroup + '\n';

body += 'Keyword: "' + item.keyword + '"\n';

body += 'Cost:

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.

+ item.cost.toFixed(2) + ' | Conversions: ' + item.conversions + ' | CPA:
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.

+ item.cpa + '\n';

body += 'Reason: ' + item.reason + '\n';

body += '--------------------------------------------------\n';

}

body += '\nLog into Google Ads to review search terms and make necessary negative keyword adjustments.';

MailApp.sendEmail(

CONFIG.NOTIFICATIONEMAIL,

'ALERT: ' + pausedList.length + ' Broad Match Keywords Paused in Google Ads',

body

);

Logger.log('Notification email sent to ' + CONFIG.NOTIFICATIONEMAIL);

}

---

Step-by-Step Implementation Guide

Installing and configuring this google ads automated cpa pause script takes less than ten minutes. Follow these exact steps to ensure safe execution.

[Tools and Settings] ── [Scripts] ── [+ New Script] ── [Paste Code] ── [Authorize] ── [Dry Run / Preview] ── [Schedule Hourly]

Step 1: Access the Script Environment

1. Sign in to your Google Ads account.

2. In the top navigation bar, click on Tools and Settings (wrench icon) or navigate to the left-hand navigation if using the refreshed UI.

3. Under Bulk Actions, click Scripts.

4. Click the blue plus button (+) to create a new script.

Step 2: Paste and Authorize the Script

1. Clear out the default function main() {} template in the editor window.

2. Paste the full code snippet provided above.

3. Click the Authorize button at the bottom right. A Google OAuth prompt will appear. Sign in with the account that has administrative access to the Google Ads property and grant the necessary permissions.

Step 3: Configure Parameters and Run a Preview Test

1. Set DRYRUN: true in line 21. This ensures that the script will only log its decisions to the console without pausing any keywords or firing emails.

2. Adjust TARGETCPA to match your account's economics. If your target is $40, enter 40.00.

3. Click Preview at the bottom right of the screen.

4. Open the Logs tab below the editor. Verify the output. Ensure the script identifies true runaway keywords and does not flag keywords you intended to keep active.

Step 4: Go Live and Set Execution Schedule

1. Once verified, set DRYRUN: false.

2. Enter your email address in NOTIFICATIONEMAIL.

3. Click Save.

4. Return to the main Scripts dashboard.

5. In the Frequency column next to your new script, select Hourly or Daily (Hourly is recommended if your daily spend exceeds $300/day).

---

Essential Safety Controls and Edge Cases

Automating keyword pauses without adequate safeguards can accidentally choke viable campaign traffic. Implement the following guardrails to protect legitimate performance.

Protecting Brand Terms

Never let a broad match script pause brand-related keywords. If you are bidding on broad match brand queries (for example, +acme software discount), conversion volume and intent are entirely different from non-brand broad match.

Ensure line 20 (CAMPAIGNNAMEDOESNOTCONTAIN: 'Brand') matches your brand campaign naming convention. For more details on brand query management, read our guide on whether you should bid on competitor brand keywords in Google Ads.

Handling Attribution Lag and Day-1 Volatility

Conversion tracking often takes between 12 and 72 hours to reflect true numbers, especially if your business relies on CRM syncs (such as HubSpot or Salesforce via Zapier or offline conversion imports).

If you set DATERANGE: 'TODAY' on a high-lag account, the script will see spend but zero recorded conversions, leading to false pauses. Use these guidelines based on business model:

• E-commerce (Instant Purchases): Set DATERANGE: 'TODAY' or 'YESTERDAY'. Click-to-conversion turnaround is fast enough to support aggressive intraday pauses.

• B2B Lead Gen (Form fills with instant tracking): Set DATERANGE: 'LAST7DAYS' with a higher MINSPENDFLOOR.

• High-Lag CRM Offline Imports: Set DATERANGE: 'LAST14DAYS' and raise ZEROCONVERSIONSPENDMULT to 3.5.

Preventing Account Starvation

If Google releases an algorithm update that spikes CPCs across your entire vertical, an aggressive script might pause 80% of your broad match keywords in an afternoon, effectively starving your campaigns of auction impressions.

To prevent this, you can add an exit clause that limits pauses to a maximum of 3 keywords per run. If the counter reaches that limit, the script pauses execution and sends an urgent notification requesting manual review.

---

Analyzing What Broke: Next Steps After a Keyword Is Paused

When the script pauses a keyword and applies the ScriptPausedRunawayCPA label, your work is not finished. A paused broad match keyword is a symptom; the underlying cause is almost always low-quality search terms matching into that keyword.

1. Interrogate the Search Terms Report

Navigate to the keyword's ad group and open the Search Terms report for the period during which the runaway spend occurred. Look for the exact queries that triggered the spend spike.

Are they matching to completely irrelevant products? Are they queries containing high-funnel keywords like "free", "salary", "jobs", or "login"? Use our deep dive on how to use the Google Ads search terms report to cut wasted spend to isolate the queries that triggered the blowout.

2. Add Systemic Negative Keywords

Do not simply re-enable the broad match keyword hoping for better results. If you re-enable it without changes, Google's algorithms will continue matching to the same queries.

Extract the toxic n-grams (single words or short phrases causing the waste) and add them to your account-level or campaign-level negative lists. Reference our curated list of 100+ negative keyword examples to proactively block known low-intent queries before broad match finds them.

3. Determine if the Keyword Should Be Re-Enabled

Review the keyword's multi-month historical return. If a broad match keyword generated a 4x ROAS over six months, the recent blowout was likely an isolated search trend anomaly. Add the necessary negatives and re-enable the keyword.

However, if the keyword has historically hovered near break-even and suddenly exploded in CPA, the broad intent is too loose. Transition that keyword to phrase match or exact match, or use a PPC audit checklist to evaluate whether your overall campaign structure requires restructuring.

---

Native Scripts vs. Autonomous AI Management

Google Ads scripts provide a free, code-level line of defense. However, scripts operate on static rules: they check whether metric $X$ is greater than value $Y$, and if so, they execute action $Z$. Modern PPC environments require contextual intelligence that scripts cannot provide.

| Feature | Custom Google Ads Script | Autonomous AI Management (e.g., AdTurbo) |

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

| Setup Complexity | Requires code editing and API authorization | No-code connection via OAuth in 2 minutes |

| Contextual Awareness | Evaluates only static thresholds (Cost, CPA) | Analyzes semantic intent behind queries |

| Search Term Resolution | Pauses parent keyword; leaves query open | Automatically isolates and negates bad queries |

| Attribution Handling | Manual date range selection | Models account-specific conversion lag dynamically |

| Bid Adjustments | Binary (Pause/Enable) | Multi-variable algorithmic micro-bidding |

| Cost | Free (requires technical maintenance) | Starts at $149/mo (7-day trial, card required) |

While a script can pause a keyword, it cannot write a new responsive search ad, shift budget to a better-performing ad group, or understand that an intraday CPA spike was caused by a temporary conversion API outage rather than bad search traffic.

If you want to move beyond manual script maintenance and run full-stack autonomous optimization, exploring a dedicated Google Ads AI agent provides continuous protection across bidding, search terms, and ad creative.

---

Related Guides

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

• Negative Keywords: 100+ Examples and Lists for Google Ads

• PPC Audit Checklist: 12 Steps to Fix a Leaking Google Ads Account

---

Frequently Asked Questions

Can running this script break my Google Ads account?

No, the script only pauses keywords that violate your defined CPA or spend thresholds and tags them with a label. It does not delete assets, change campaign structures, or adjust account-level budgets. You can test it safely by leaving DRYRUN: true enabled during preview mode.

Do Google Ads scripts work with Performance Max campaigns?

No, standard Google Ads keyword scripts cannot interact with Performance Max campaigns because Performance Max does not use traditional keyword entities. PMax optimization requires asset group evaluations, listing group bid adjustments, and account-level negative lists managed via API or external management tools.

How often should this auto-pause script run?

For accounts spending over $10,000 per month with broad match enabled, running the script hourly is recommended to catch runaway search terms within hours. For smaller accounts spending under $3,000 monthly, running the script once daily at midnight or early morning is sufficient.

How do I re-enable a keyword paused by the script?

Filter your keyword table by the label applied by the script (ScriptPausedRunawayCPA). Once you review the search terms, add relevant negative keywords to prevent the offending queries from matching again, change the keyword status back to Enabled, and remove the label.

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.