Stop ROAS Collapse: Custom Script to Auto-Pause Ad Groups
Deploy a custom Google Ads script to auto-pause ad groups facing a 72-hour ROAS degradation. Protect spend, tackle attribution lag, and preserve margins.
By AdTurbo Team · 2026-12-02
A sudden dip in Return on Ad Spend (ROAS) can erase a month of profitability in a single weekend. When ad groups run unchecked during sudden demand slumps, broken landing pages, or competitor price wars, Smart Bidding often lags behind, consuming your budget while waiting for conversion signals that never materialize.
Building a tailored solution—like a google ads roas degradation script—allows you to intervene dynamically. While native automated rules can pause campaigns when total spend hits a flat ceiling, they lack the rolling-window nuance required to detect structural degradation without overreacting to daily volatility.
This guide breaks down how to build, deploy, and refine an enterprise-grade Google Ads script that audits 72-hour rolling performance, detects genuine ROAS collapses, and automatically pauses hemorrhaging ad groups before your budget drains.
---
Why ROAS Fails: The Mathematical Case for Margin-Aware Automation
Most performance marketing teams evaluate success through a aggregate Return on Ad Spend (ROAS) metric. However, standard ROAS contains a fatal blind spot: it assumes all revenue dollars carry identical value.
ROAS = Gross Conversion Value / Total Ad Spend
If Ad Group A generates $10,000 in revenue from $5,000 in spend, its ROAS is 2.0x (200%). If Ad Group B generates $4,000 in revenue from $1,000 in spend, its ROAS is 4.0x (400%). At a glance, Ad Group B appears superior. But if Ad Group A sells high-margin software (85% gross margin) while Ad Group B sells drop-shipped electronics (15% gross margin), the reality shifts:
• Ad Group A Profit: ($10,000 0.85) - $5,000 = $3,500 net contribution
• Ad Group B Profit: ($4,000 0.15) - $1,000 = -$400 net contribution (a loss)
The Flaw in Raw ROAS Mechanics
When an ad group’s conversion volume suddenly stalls, standard Google Ads bid strategies (like Target ROAS) attempt to adjust by bidding down or altering query matching. However, if your target ROAS threshold is set indiscriminately across varied product catalogs, the algorithm may continue funneling spend into ad groups that produce revenue below your break-even threshold.
When conversion rates drop due to an out-of-stock primary SKU or external market shifts, automated systems often burn substantial spend attempting to regain statistical confidence before finally restricting delivery.
Defining Profit on Ad Spend (POAS)
To build an automation safeguard that actually protects your bottom line, advanced script architectures increasingly look at POAS (Profit on Ad Spend) or incorporate gross margin multipliers directly into script logic:
POAS = Gross Profit Generated / Total Ad Spend
A POAS above 1.0 indicates real-world profitability after ad costs. If you pass net profit values into Google Ads conversion tracking, you can swap raw revenue for gross profit metrics inside your scripts. If you only track top-line revenue, your scripts must enforce conservative, tiered thresholds that reflect your blended gross margin floor.
---
The Fallacy of 24-Hour Panics: Why 72-Hour Degradation Beats 24 and 48-Hour Rules
When media buyers decide to automate pausing ad groups low roas, their first instinct is often to write a script evaluating yesterday's numbers. This is one of the most destructive mistakes you can make with Smart Bidding.
The Volatility of Single-Day Windows
Single-day conversion spikes and valleys are often noise, not signal. A consumer might click a Search ad on Tuesday afternoon, research alternative solutions on Wednesday, and complete the checkout on Thursday.
If you run an automated script on Wednesday morning looking exclusively at Tuesday's 0.6x ROAS, you will pause an ad group that would have recorded a 3.5x ROAS by Friday once conversion attribution reconciles. Pausing assets prematurely starves Smart Bidding of its most profitable paths and forces campaigns back into exploratory bidding states.
Why 48-Hour Windows Still Misfire on Lag
Many basic scripts rely on a 48-hour check. While 48 hours is noticeably better than a single-day snapshot, it frequently causes false positives for accounts with:
1. High Average Order Values (AOV $150)
2. B2B lead generation flows involving multi-step forms
3. Non-click conversion interactions (e.g., cross-device journeys)
Under a 48-hour rule, normal weekend volume dips can trigger automated pauses if Friday and Saturday performance registers below target, needlessly killing ad groups that would balance out on Monday.
The Structural Logic of 72-Hour Degradation
A 72-hour rolling evaluation window bridges the gap between account protection and statistical validity. Three full days allow enough conversion volume to accumulate, smoothing out day-of-week seasonality (such as weekend dips in B2B or weekday dips in recreational retail) while providing immediate protection if performance completely collapses.
| Evaluation Window | False Positive Rate | Protection Speed | Best Suited For |
| :--- | :--- | :--- | :--- |
| 24 Hours | Extremely High (40–60%) | Immediate (Under 24h) | Broken URL / 404 Emergency Checks |
| 48 Hours | Moderate (15–25%) | Fast (48h) | High-volume, low-AOV impulse e-commerce |
| 72 Hours | Low (3–7%) | Balanced (72h) | Scaled Search, Performance Max, and High AOV |
| 7 Days | Negligible (<1%) | Too Slow (Burns budget) | Strategic macro-budget reallocations |
By requiring both minimum statistical spend and consecutive daily sub-par performance over 72 hours, you protect your capital without throttling your account's algorithmic momentum.
---
Complete Google Ads Script: Auto-Pause Ad Groups on 72-Hour ROAS Degradation
Below is the complete, production-ready Google Ads Script. It checks your enabled ad groups, calculates their ROAS across a trailing 72-hour window (excluding today to prevent incomplete day-parting anomalies), confirms whether spend exceeds your statistical threshold, and pauses any ad group that fails to meet your minimum floor.
It also labels paused ad groups automatically, ensuring your team can review exactly what was changed and why.
javascript
/
• Google Ads Script: Auto-Pause Ad Groups on 72-Hour ROAS Degradation
• Evaluates ad groups against a trailing 3-day performance window.
• Applies a protective label and sends email notifications upon execution.
/
const CONFIG = {
// Minimum ROAS required over the 72-hour window (e.g., 1.5 = 150% ROAS)
TARGETROASFLOOR: 1.25,
// Minimum spend required in the last 72 hours before script can take action
MINSPENDTHRESHOLD: 150.00,
// Label applied to ad groups paused by this script
PAUSELABEL: 'PausedROASDegradation72h',
// Email addresses to notify (comma-separated)
NOTIFICATIONEMAILS: '[email protected]',
// Set to true to execute changes; set to false to test without pausing
LIVEMODE: true,
// Names of campaigns to exclude (case-insensitive substring)
EXCLUDEDCAMPAIGNS: ['Brand', 'Catch-All']
};
function main() {
Logger.log('Starting 72-Hour ROAS Degradation Audit...');
ensureLabelExists(CONFIG.PAUSELABEL);
const pausedAdGroups = [];
const dateRange = getTrailing72HoursDateRange();
Logger.log('Auditing performance between ' + dateRange.startDate + ' and ' + dateRange.endDate);
const query =
SELECT
campaign.id,
campaign.name,
adgroup.id,
adgroup.name,
adgroup.status,
metrics.costmicros,
metrics.conversionsvalue
FROM adgroup
WHERE
adgroup.status = 'ENABLED'
AND campaign.status = 'ENABLED'
AND metrics.costmicros 0
AND segments.date BETWEEN '${dateRange.startDate}' AND '${dateRange.endDate}'
;
const searchResults = AdsApp.search(query);
// Group metrics by Ad Group ID to aggregate the 3-day rolling window
const adGroupData = {};
while (searchResults.hasNext()) {
const row = searchResults.next();
const campaignName = row.campaign.name;
const adGroupId = row.adGroup.id;
const adGroupName = row.adGroup.name;
const cost = row.metrics.costMicros / 1000000;
const conversionValue = row.metrics.conversionsValue || 0;
// Skip excluded campaigns
if (CONFIG.EXCLUDEDCAMPAIGNS.some(excluded = campaignName.toLowerCase().includes(excluded.toLowerCase()))) {
continue;
}
if (!adGroupData[adGroupId]) {
adGroupData[adGroupId] = {
id: adGroupId,
name: adGroupName,
campaignName: campaignName,
totalCost: 0,
totalValue: 0
};
}
adGroupData[adGroupId].totalCost += cost;
adGroupData[adGroupId].totalValue += conversionValue;
}
// Evaluate aggregated metrics against safety thresholds
for (const id in adGroupData) {
const group = adGroupData[id];
if (group.totalCost = CONFIG.MINSPENDTHRESHOLD) {
const rollingRoas = group.totalValue / group.totalCost;
if (rollingRoas < CONFIG.TARGETROASFLOOR) {
Logger.log(Ad Group Degradation Detected: "${group.name}" in Campaign "${group.campaignName}");
Logger.log(Spend: ${group.totalCost.toFixed(2)} | Value: ${group.totalValue.toFixed(2)} | ROAS: ${rollingRoas.toFixed(2)});
if (CONFIG.LIVEMODE) {
pauseAdGroup(group.id, group.name, CONFIG.PAUSELABEL);
} else {
Logger.log([DRY RUN] Would pause Ad Group ID: ${group.id});
}
pausedAdGroups.push({
campaign: group.campaignName,
adGroup: group.name,
spend: group.totalCost.toFixed(2),
revenue: group.totalValue.toFixed(2),
roas: rollingRoas.toFixed(2)
});
}
}
}
// Notify team via email if assets were paused
if (pausedAdGroups.length 0 && CONFIG.NOTIFICATIONEMAILS) {
sendAlertEmail(pausedAdGroups);
}
Logger.log('Audit complete. Processed ' + Object.keys(adGroupData).length + ' active ad groups.');
}
function getTrailing72HoursDateRange() {
const now = new Date();
const timeZone = AdsApp.currentAccount().getTimeZone();
// End date is yesterday (D-1) to avoid partial-day conversion data skew
const endDateObj = new Date(now.getTime() - (1 24 60 60 1000));
// Start date is 3 days prior to yesterday (D-3)
const startDateObj = new Date(now.getTime() - (3 24 60 60 1000));
return {
startDate: Utilities.formatDate(startDateObj, timeZone, 'yyyy-MM-dd'),
endDate: Utilities.formatDate(endDateObj, timeZone, 'yyyy-MM-dd')
};
}
function pauseAdGroup(adGroupId, adGroupName, labelName) {
const adGroupIterator = AdsApp.adGroups().withIds([adGroupId]).get();
if (adGroupIterator.hasNext()) {
const adGroup = adGroupIterator.next();
adGroup.pause();
adGroup.applyLabel(labelName);
Logger.log(Successfully paused and labeled ad group: ${adGroupName});
}
}
function ensureLabelExists(labelName) {
const labelIterator = AdsApp.labels().withCondition(Name = '${labelName}').get();
if (!labelIterator.hasNext()) {
AdsApp.createLabel(labelName, 'Applied automatically by 72-hour ROAS safeguard script', 'red');
Logger.log(Created new label: ${labelName});
}
}
function sendAlertEmail(actionsList) {
let body = 'The 72-Hour ROAS Degradation Safeguard Script has paused the following ad groups:\n\n';
actionsList.forEach(item = {
body += Campaign: ${item.campaign}\n;
body += Ad Group: ${item.adGroup}\n;
body += 72-Hour Spend: ${item.spend}\n;
body += 72-Hour Revenue: ${item.revenue}\n;
body += Realized ROAS: ${item.roas}x\n;
body += '--------------------------------------------------\n';
});
body += '\nPlease review these ad groups before manually reactivating them.';
MailApp.sendEmail(
CONFIG.NOTIFICATIONEMAILS,
[URGENT] Google Ads Safeguard: ${actionsList.length} Ad Group(s) Paused,
body
);
Logger.log('Notification email dispatched.');
}
---
Step-by-Step Implementation & Setup Instructions
Deploying custom scripts requires testing within the Google Ads sandbox environment to ensure permissions and syntax match your account structure.
Step 1: Access the Scripts Management Interface
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 navigation interface).
3. Under the Bulk Actions column, select Scripts.
4. Click the blue + button to create a new script.
Step 2: Paste and Customize the Script Configuration
1. Clear any default code in the editor window.
2. Paste the full script provided in the section above.
3. Customize the CONFIG values:
• TARGETROASFLOOR: Set this to your account's break-even margin threshold. If you need a 200% ROAS to stay profitable, set this to 2.0 or slightly below (e.g., 1.8) to avoid over-pausing minor swings.
• MINSPENDTHRESHOLD: Avoid pausing ad groups on tiny sample sizes. If your average cost-per-click (CPC) is $3, setting a $150 minimum ensures at least 50 clicks occurred before the script evaluates performance.
• LIVEMODE: Set this to false for your initial setup.
• NOTIFICATIONEMAILS: Enter the addresses that should receive the execution alerts.
Step 3: Authorize and Preview
1. Click the Authorize button at the bottom right of the screen. Follow Google's OAuth prompts to grant the script permission to manage ad groups and dispatch emails.
2. Click Preview.
3. Check the Logs tab at the bottom of the screen. Verify that the script pulls your campaigns accurately, identifies correct rolling spend totals, and demonstrates what it would have paused without making live changes.
Step 4: Schedule Daily Automated Execution
1. Once you confirm the preview logs match your expectations, switch LIVEMODE: true in the CONFIG object.
2. Click Save.
3. Return to the main Scripts overview table.
4. In the Frequency column, choose Daily, and schedule the execution time for early morning (between 4:00 AM and 6:00 AM in your account's primary timezone). This ensures all data from the previous day has settled.
If you find yourself constantly adjusting manual scripts across several accounts, you might explore modern alternatives. Using a dedicated Google Ads automation system or a specialized Google Ads AI agent can manage rolling degradation curves natively across campaigns without requiring custom code maintenance.
---
Handling Attribution Lag, Lookback Windows, and Edge Cases
Even a well-configured 72-hour window requires tactical adjustments depending on your business model and data maturity.
The Challenge of Conversion Attribution Lag
Not all conversions happen within minutes of an ad interaction. According to Google Ads platform data, the average e-commerce account experiences an attribution lag where 15–30% of total conversion value registers between 24 and 72 hours after the click. In B2B SaaS, this lag can stretch across weeks.
To identify your account's true conversion lag:
1. Navigate to Goals Attribution Path Metrics.
2. Check Days to Conversion.
3. If more than 20% of your conversions occur after Day 3, a strict 72-hour script auto pause ad group roas collapse protocol will register premature actions.
Mitigation Strategy:
Add an attribution multiplier inside the script logic. For example, if your historical data demonstrates that 72-hour conversion totals represent exactly 80% of final conversion value, adjust your script evaluation threshold:
const adjustedRoas = rollingRoas 1.25;
Diagnosing Root Causes Before Permanent Deactivation
When an ad group is paused by a script, treat it as a symptom rather than the primary disease. Immediately audit the following points before assuming the product or keywords are dead:
• Search Intent Shift: Did an algorithmic change match your broad match keywords to irrevelant search terms? Review our guide on how to use the Google Ads search terms report to cut wasted spend.
• Landing Page Errors: Check whether the landing page returned 404 or 500 status codes. Run a routine account health check using this PPC audit checklist to isolate technical drop-offs.
• Tracking Tag Failures: Check if Google Tag Manager or your primary conversion tags failed. If your script pauses every ad group in an entire campaign simultaneously, your conversion tracking is likely broken, not your ads.
---
Re-enabling Paused Ad Groups: Automated vs. Manual Safeguards
One common question growth engineers ask is: "Can we write an auto-unpause function that turns ad groups back on next week?"
The Problem with Auto-Enabling Paused Assets
Automating the reactivation of paused ad groups is dangerous. If an ad group was paused because it generated $200 in cost for $0 in value over three days, turning it back on automatically after 48 hours without changing its underlying context (keywords, bids, target URLs, or offers) will simply burn another $200.
Furthermore, repeatedly cycling ad groups between ENABLED and PAUSED states damages Smart Bidding models, resetting micro-learning loops and inflating your average CPCs.
[ Script Detects 72h ROAS Drop ]
│
▼
[ Auto-Pause Ad Group & Apply Label ]
│
▼
[ Manual Root Cause Investigation ]
│
┌────────────────┴────────────────┐
▼ ▼
[ Issue Fixed ], [ Dead Weight ]
(e.g., negative keywords, (Uncompetitive product,
fixed landing page) structurally unprofitable)
│ │
▼ ▼
[ Remove Label & Unpause ], [ Keep Permanently Paused ]
Structured Reactivation Protocol
Instead of automating reactivations, apply this structured protocol:
1. Filter by Label: Filter the ad group grid by the label generated by the script (PausedROASDegradation72h).
2. Examine Search Queries: Check for non-converting search term clusters and isolate them by learning how to find negative keywords in Google Ads.
3. Audit Competitive Pricing: If you are running Google Shopping or Search ads for retail products, verify whether a competitor launched an aggressive promo that degraded your conversion rate over the last 3 days.
4. Controlled Re-Entry: Once adjustments are made, remove the label, unpause the ad group manually, and monitor it closely for the subsequent 48 hours.
---
Script Maintenance, API Limits, and Scaling to Full Automation
While Google Ads Scripts offer a flexible stopgap, they present architectural constraints that growth teams encounter as budgets scale.
Technical Limitations of Google Ads Scripts
• Execution Timeouts: Google Ads Scripts have a hard execution limit of 30 minutes for single accounts (and 60 minutes in manager accounts). If your account contains tens of thousands of active ad groups, the script may time out before evaluating all entities.
• GAQL Quota Limits: Excessive reporting queries run through the Google Ads Query Language (GAQL) can trigger API quota errors during peak processing hours.
• Entity Lag: Changes made via scripts do not always reflect instantly in reporting pipelines, occasionally causing scripts to fire duplicate alerts if executed too frequently.
Transitioning from Scripts to AI Management
Custom scripts are linear: if condition X occurs, execute action Y. But modern account optimization rarely follows a straight line. If ROAS drops because an ad group was tested on a higher target CPA or expanded into broader audience signals, an automated script blindly kills the test before the bidding algorithm completes its exploratory phase.
Teams running substantial monthly spend often outgrow rigid JavaScript snippets. Advanced platforms, like the PPC management software provided by AdTurbo ($149/mo with a 7-day trial; credit card required), replace rigid static rules with adaptive multi-variable oversight.
AdTurbo evaluates ad groups dynamically—weighing conversion lag, keyword intent shifts, and seasonal variations before taking calculated corrective measures. This delivers the safety of an automated floor without the operational overhead of managing brittle, manual scripts.
---
Related Guides
• Google Ads Optimization Checklist: 15 Things to Check Every Week
• PPC Audit Checklist: 12 Steps to Fix a Leaking Google Ads Account
• How to Use the Google Ads Search Terms Report to Cut Wasted Spend
---
Frequently Asked Questions
Can I run this script on Performance Max campaigns?
No, standard Google Ads scripts that target the adgroup entity cannot pause individual asset groups within Performance Max campaigns. Performance Max architecture uses assetgroup entities, which currently have restricted programmatic write access through standard Google Ads Scripts; PMax controls must be handled at the campaign level or managed through external API integrations.
What should I do if an ad group is paused incorrectly due to delayed conversions?
If conversions register after the ad group has been paused, verify your attribution lag by inspecting the Days to Conversion report under Path Metrics. If delayed conversions push the historical 72-hour ROAS back above your target threshold, manually remove the script label and reactivate the ad group. You should also raise the MINSPENDTHRESHOLD or adjust the evaluation window to 96 hours to accommodate your sales cycle.
Will pausing ad groups with a script reset Smart Bidding learning phases?
Pausing an ad group for a brief period (less than 7 consecutive days) typically does not reset the campaign-level Smart Bidding learning phase, as portfolio and campaign bidding algorithms retain macro-level historical conversion data. However, letting an ad group sit paused for extended periods or repeatedly pausing and unpausing it on alternating days can degrade bidding stability and trigger exploratory phases once re-enabled.