Script: Auto-Pause Shopping Campaigns on 24H POAS Collapse
Learn how to build and deploy a Google Ads script to auto-pause Shopping campaigns on a 24-hour POAS collapse. Protect margins with real-time automation.
By AdTurbo Team · 2026-11-30
Top-line revenue is a vanity metric that ruins e-commerce margins. An e-commerce brand can pull in $20,000 in top-line revenue over 24 hours at a 400% Return on Ad Spend (ROAS), yet lose money once product Cost of Goods Sold (COGS), gateway transaction fees, and shipping overhead are deducted.
Standard Google Ads automated bidding strategies optimize for conversion value or volume. They do not optimize for bottom-line cash. When a sudden supply chain price surge hits, an affiliate undercuts pricing, or a high-volume product with paper-thin margins dominates conversions, your account can bleed thousands of dollars in pure margin before manual audits catch the problem.
Implementing a script to auto pause shopping campaigns poas collapse safeguards your cash flow. By calculating Profit on Ad Spend (POAS) dynamically and scanning your performance on a trailing 24-hour intraday basis, custom Google Ads Scripts provide a programmatic failsafe that halts ad spend the instant profitability drops below break-even.
---
Why ROAS Fails and Blended POAS Must Dictate Campaign Control
Most e-commerce media buyers build their optimization playbooks around target ROAS (tROAS). However, standard ROAS assumes every dollar of reported conversion value carries identical margin. In a standard Shopping or Performance Max campaign with mixed-margin catalogs, that assumption causes structural budget waste.
The ROAS Illusion vs. Real Margin
Consider two products generating the exact same revenue inside a Standard Shopping campaign:
• Product A (Consumer Tech Accessory): $100 Retail Price, 80% Gross Margin. Unit gross profit: $80.
• Product B (Branded Hardware Component): $100 Retail Price, 15% Gross Margin. Unit gross profit: $15.
If your campaign spends $50 to acquire one sale for each product:
• Product A: Generates $100 revenue on $50 spend = 200% ROAS. Net Profit after ad spend = $30 ($80 gross profit − $50 ad spend). Profitable.
• Product B: Generates $100 revenue on $50 spend = 200% ROAS. Net Profit after ad spend = -$35 ($15 gross profit − $50 ad spend). Loss-making.
Google Ads Smart Bidding treats both outcomes identically because both produced a 2.0 ROAS. If a campaign suddenly tilts toward lower-margin inventory, your reported dashboard ROAS can remain perfectly stable while your bank balance drops. If you run complex enterprise accounts, working through a structured PPC audit checklist reveals that margin misallocation is one of the most common causes of wasted ad spend.
Defining Blended POAS (Profit on Ad Spend)
POAS measures the actual gross profit generated per dollar of advertising spend.
$\text{POAS} = \frac{\text{Gross Profit}},{\text{Ad Spend}} = \frac{\text{Net Revenue} - \text{COGS} - \text{Direct Processing Fees}},{\text{Ad Spend}}$
• POAS 1.0: The campaign covers its ad spend and product costs, generating positive net operating contribution.
• POAS = 1.0: Absolute break-even. Every dollar of gross margin goes directly to Google to cover the click cost.
• POAS < 1.0: The campaign is actively losing money on a variable unit basis.
Monitoring POAS over standard 30-day windows is standard practice, but it is too slow to stop acute intraday margin collapses. An intraday poas pause script shopping protocol runs every few hours to evaluate the trailing 24-hour window, automatically pausing campaigns or ad groups when trailing performance drops below your break-even threshold.
---
Custom POAS Scripts vs. Google Native Automation
Media buyers often ask why native platform controls are insufficient. Google Ads includes several automated rules, Smart Bidding features, and policy automations, but none protect intraday gross margin.
Clarifying Google Automatic Low-Activity Ad Group Policy
Google actively pauses ad groups and assets that it deems "low-activity"—meaning assets with zero impressions over an extended duration (typically 13 continuous months). This feature serves Google's infrastructure needs by clearing out dead inventory. It has no relationship with financial efficiency, margin thresholds, or ROAS degradation.
Similarly, automated rules within the Google Ads UI can adjust budgets or pause campaigns based on metrics like Cost, Conversions, or Conversion Value / Cost (ROAS). However, the native UI rules engine cannot ingest dynamic external COGS matrices, factor in variable margin labels, or process cross-system net margins on the fly.
| Operational Capability | Google Native Rules / Smart Bidding | Custom Intraday POAS Script |
| :--- | :--- | :--- |
| Core Metric Evaluated | ROAS / Conversion Value | Net POAS (Profit on Ad Spend) |
| COGS Ingestion | Requires complex backend offline uploads | Direct formula calculation or Sheets lookup |
| Trailing 24-Hour Evaluation | Limited intraday attribution updates | Dynamic rolling 24-hour window checks |
| Custom Margin by Product Type | Requires setting separate tROAS targets manually | Automated margin coefficients via Custom Labels |
| Auto-Logging to Google Sheets | No (System Change History only) | Real-time structured Google Sheet audit trail |
| Slack / Email Alert Payloads | Generic UI email alerts | Dynamic, payload-rich margin collapse alerts |
For businesses that want continuous cross-account margin defense without maintaining custom scripts, using an advanced platform like AdTurbo's PPC management software provides automated margin tracking and budget protection directly out of the box.
---
The Mathematical Architecture of a POAS Script
To make an automated pause script work, you must define how gross margin is calculated inside the script environment. Depending on your backend technical maturity, you can select one of two primary architectural models.
Model A: Standard Gross Margin Coefficient (Label-Driven)
Model A uses predetermined gross margin percentages assigned at the campaign, ad group, or custom label tier. This model is ideal for e-commerce accounts organizing inventory into structural margin buckets:
• High-Margin Campaigns (e.g., Private Label, 70% Gross Margin)
• Medium-Margin Campaigns (e.g., Licensed Apparel, 45% Gross Margin)
• Low-Margin Campaigns (e.g., Third-party Electronics, 18% Gross Margin)
In this model, the script calculates trailing gross profit using a fixed coefficient:
$\text{Gross Profit} = \text{Conversion Value} \times \text{Margin Coefficient}$
$\text{POAS} = \frac{\text{Conversion Value} \times \text{Margin Coefficient}},{\text{Cost}}$
If a campaign configured with a 40% margin coefficient spends $800 over the past 24 hours and generates $1,600 in conversion value:
$\text{Gross Profit} = \$1,600 \times 0.40 = \$640$
$\text{POAS} = \frac{\$640},{\$800} = 0.80$
Because 0.80 is below the break-even threshold of 1.0, the script triggers an automatic pause.
Model B: Custom Conversion Ingestion (Direct Profit Value)
In Model B, your backend (e.g., Shopify via webhook, BigCommerce, or your ERP) sends net gross profit directly into Google Ads as the primary conversion value, rather than raw top-line order revenue.
When your conversion tag or server-side API passes grossprofit as the conversion value, the native ConversionValue returned by the Google Ads reporting API is your profit. In this scenario, the script calculation simplifies to:
$\text{POAS} = \frac{\text{Conversion Value}},{\text{Cost}}$
Under Model B, any campaign where ConversionValue / Cost < 1.0 is operating at a net loss on that trailing window.
Handling Attribution Delay and Lookback Windows
Attribution lag is the main challenge with intraday automations. If a shopper clicks a Shopping ad at 9:00 AM but completes checkout at 7:00 PM, an intraday script evaluating performance at 2:00 PM will see the $40 click cost without the corresponding $120 conversion value. Pausing campaigns prematurely due to data lag is a common automation error. If you are diagnosing broader performance swings across your account, review our diagnostic guide on Google Ads not working.
To prevent attribution lag from triggering false-positive pauses, your script architecture must include two safety filters:
1. Statistical Significance Spend Floor: The script will only evaluate campaigns or ad groups once their trailing 24-hour spend exceeds a set dollar floor (e.g., 3x your historical Account CPA or a minimum of $150).
2. Lookback Buffer: For products with longer conversion paths, evaluate a rolling LAST24HOURS window offset by 2 to 4 hours, or use a trailing 48-hour window with higher thresholds.
Timeline: [--- 24-Hour Evaluation Period ---], [--- 3-Hour Lag Buffer ---] (Current Execution Time)
---
Complete Google Ads Script Code: Auto-Pause Low Blended POAS
The production-ready JavaScript code below uses the modern Google Ads Scripts engine (incorporating the AdsApp.search resource with Google Ads Query Language / GAQL). It checks trailing performance, calculates POAS based on your defined margin coefficients, pauses underperforming entities, logs actions to Google Sheets, and sends an email alert summary.
Full JavaScript Code
javascript
/
• Auto-Pause Shopping Campaigns & Ad Groups on 24-Hour POAS Collapse
• Version: 2.4
• Maintained for Google Ads Scripts (New Engine)
/
const CONFIG = {
SPREADSHEETURL: 'YOURSPREADSHEETURLHERE',
SHEETNAME: 'ActionLog',
EMAILRECIPIENTS: '[email protected]',
DEFAULTMARGINCOEFFICIENT: 0.45, // 45% gross margin default
POASTHRESHOLD: 1.05, // Pause if POAS falls below 1.05
MINSPENDTHRESHOLD: 150.00, // Minimum spend in last 24h to trigger evaluation
DRYRUN: true, // Set to FALSE to apply real pauses
CAMPAIGNNAMECONTAINS: 'Shopping', // Filter specific campaigns (case-insensitive)
APPLYTOLEVEL: 'CAMPAIGN' // Options: 'CAMPAIGN' or 'ADGROUP'
};
function main() {
const sheet = initSheet();
const todayFormatted = Utilities.formatDate(new Date(), AdsApp.currentAccount().getTimeZone(), 'yyyy-MM-dd HH:mm:ss');
const alerts = [];
Logger.log('Starting POAS Collapse Evaluation at: ' + todayFormatted);
Logger.log('Mode: ' + (CONFIG.DRYRUN ? 'DRY-RUN (No changes applied)' : 'LIVE (Changes will be executed)'));
if (CONFIG.APPLYTOLEVEL === 'CAMPAIGN') {
evaluateCampaigns(sheet, alerts);
} else if (CONFIG.APPLYTOLEVEL === 'ADGROUP') {
evaluateAdGroups(sheet, alerts);
} else {
throw new Error('Invalid CONFIG.APPLYTOLEVEL. Select CAMPAIGN or ADGROUP.');
}
if (alerts.length 0 && CONFIG.EMAILRECIPIENTS !== '') {
sendEmailAlert(alerts);
}
}
function evaluateCampaigns(sheet, alerts) {
const query =
SELECT
campaign.id,
campaign.name,
campaign.status,
metrics.costmicros,
metrics.conversionsvalue
FROM campaign
WHERE campaign.status = 'ENABLED'
AND segments.date DURING LAST1DAYS
;
const searchResults = AdsApp.search(query);
while (searchResults.hasNext()) {
const row = searchResults.next();
const campaignName = row.campaign.name;
const campaignId = row.campaign.id;
if (CONFIG.CAMPAIGNNAMECONTAINS && !campaignName.toLowerCase().includes(CONFIG.CAMPAIGNNAMECONTAINS.toLowerCase())) {
continue;
}
const cost = parseFloat(row.metrics.costMicros) / 1000000.0;
const convValue = parseFloat(row.metrics.conversionsValue || 0);
if (cost < CONFIG.MINSPENDTHRESHOLD) {
continue; // Skip entities without enough statistical significance
}
const grossProfit = convValue CONFIG.DEFAULTMARGINCOEFFICIENT;
const poas = cost 0 ? (grossProfit / cost) : 0;
if (poas < CONFIG.POASTHRESHOLD) {
const logMessage = Campaign '${campaignName}' [ID: ${campaignId}] collapsed. Cost: ${cost.toFixed(2)}, ConvVal: ${convValue.toFixed(2)}, POAS: ${poas.toFixed(2)} (Threshold: ${CONFIG.POASTHRESHOLD});
Logger.log(logMessage);
if (!CONFIG.DRYRUN) {
const campaignIterator = AdsApp.campaigns().withIds([campaignId]).get();
if (campaignIterator.hasNext()) {
const camp = campaignIterator.next();
camp.pause();
camp.applyLabel('POASPAUSED');
}
}
logToSheet(sheet, [new Date(), 'CAMPAIGN', campaignId, campaignName, cost, convValue, poas, CONFIG.DRYRUN ? 'SIMULATEDPAUSE' : 'PAUSED']);
alerts.push(logMessage);
}
}
}
function evaluateAdGroups(sheet, alerts) {
const query =
SELECT
campaign.id,
campaign.name,
adgroup.id,
adgroup.name,
adgroup.status,
metrics.costmicros,
metrics.conversionsvalue
FROM adgroup
WHERE campaign.status = 'ENABLED'
AND adgroup.status = 'ENABLED'
AND segments.date DURING LAST1DAYS
;
const searchResults = AdsApp.search(query);
while (searchResults.hasNext()) {
const row = searchResults.next();
const campaignName = row.campaign.name;
const adGroupName = row.adGroup.name;
const adGroupId = row.adGroup.id;
if (CONFIG.CAMPAIGNNAMECONTAINS && !campaignName.toLowerCase().includes(CONFIG.CAMPAIGNNAMECONTAINS.toLowerCase())) {
continue;
}
const cost = parseFloat(row.metrics.costMicros) / 1000000.0;
const convValue = parseFloat(row.metrics.conversionsValue || 0);
if (cost < CONFIG.MINSPENDTHRESHOLD) {
continue;
}
const grossProfit = convValue CONFIG.DEFAULTMARGINCOEFFICIENT;
const poas = cost 0 ? (grossProfit / cost) : 0;
if (poas < CONFIG.POASTHRESHOLD) {
const logMessage = AdGroup '${adGroupName}' in Camp '${campaignName}' collapsed. Cost: ${cost.toFixed(2)}, ConvVal: ${convValue.toFixed(2)}, POAS: ${poas.toFixed(2)};
Logger.log(logMessage);
if (!CONFIG.DRYRUN) {
const agIterator = AdsApp.adGroups().withIds([adGroupId]).get();
if (agIterator.hasNext()) {
const ag = agIterator.next();
ag.pause();
ag.applyLabel('POASPAUSED');
}
}
logToSheet(sheet, [new Date(), 'ADGROUP', adGroupId, ${campaignName} ${adGroupName}, cost, convValue, poas, CONFIG.DRYRUN ? 'SIMULATEDPAUSE' : 'PAUSED']);
alerts.push(logMessage);
}
}
}
function initSheet() {
try {
const ss = SpreadsheetApp.openByUrl(CONFIG.SPREADSHEETURL);
let sheet = ss.getSheetByName(CONFIG.SHEETNAME);
if (!sheet) {
sheet = ss.insertSheet(CONFIG.SHEETNAME);
sheet.appendRow(['Timestamp', 'Level', 'Entity ID', 'Entity Name', 'Trailing Cost', 'Trailing Value', 'Calculated POAS', 'Action Taken']);
}
return sheet;
} catch (e) {
Logger.log('Could not connect to Google Sheet. Check permissions and URL: ' + e.message);
return null;
}
}
function logToSheet(sheet, rowData) {
if (sheet) {
sheet.appendRow(rowData);
}
}
function sendEmailAlert(alerts) {
const subject = ⚠️ Google Ads Alert: ${alerts.length} Shopping Entities Paused on Low POAS;
const body = The following items breached your minimum POAS threshold (${CONFIG.POASTHRESHOLD}) over the trailing 24 hours:\n\n +
alerts.join('\n\n') +
\n\nReview your Google Ads account: https://ads.google.com;
MailApp.sendEmail(CONFIG.EMAILRECIPIENTS, subject, body);
}
---
Code Walkthrough and Configuration Variables
Understanding the core variables in the CONFIG object ensures you do not pause profitable campaigns accidentally.
Key Parameters
• SPREADSHEETURL: The full URL of the Google Sheet created to maintain the audit log. The account executing the script must have edit access.
• DEFAULTMARGINCOEFFICIENT: Set to 0.45 above, representing an average 45% gross margin. If conversion value is $1,000, the script assumes gross profit is $450. Adjust this to reflect your blended catalog margins.
• POASTHRESHOLD: Set to 1.05. If your profit divided by your ad spend is less than 1.05, you are essentially paying Google to move units without retaining operating margin.
• MINSPENDTHRESHOLD: Set to $150.00. This prevents edge cases where an ad group spends $8.00 at 8:00 AM, records zero sales, registers a POAS of 0.0, and gets paused before receiving enough traffic to convert.
• DRYRUN: Defaults to true. This simulation mode calculates metrics and populates logs without pausing any campaigns. Always execute at least three simulated runs before flipping to false.
• APPLYTOLEVEL: Toggle between CAMPAIGN and ADGROUP. Ad group control is recommended if you run product-line divisions within unified campaigns.
Automated Labeling
Notice lines 74 and 124: camp.applyLabel('POASPAUSED'). Before deploying, navigate to Tools Shared Library Labels inside Google Ads and create the label POASPAUSED.
This label ensures you can filter for paused entities and separate scripts-paused campaigns from items you turned off manually during standard catalog maintenance.
---
Step-by-Step Implementation: Installing the Script
Deploying custom automation scripts takes less than 15 minutes in the Google Ads console. Follow these steps to install the script safely.
Step 1: Setting Up the Configuration Spreadsheet
1. Open Google Sheets and create a blank spreadsheet named Google Ads POAS Guardrail Log.
2. Copy the spreadsheet URL from your browser address bar.
3. Paste the URL into line 9 of the script code (CONFIG.SPREADSHEETURL).
Step 2: Adding and Authorizing the Script in Google Ads
1. Sign in to your Google Ads account.
2. Click Tools and Settings (wrench icon) or navigate to the left navigation bar and select Tools Bulk Actions Scripts.
3. Click the blue + button to create a new script.
4. Clear all placeholder text in the code editor window.
5. Copy the code provided above and paste it into the editor.
6. Click Authorize at the bottom right. An authorization dialog appears. Select your primary Google Ads administrative email and approve the requested OAuth permissions (access to Google Sheets, Ads data, and Gmail sending capabilities).
[Google Ads Tools] ➔ [Bulk Actions] ➔ [Scripts] ➔ [+] Add New Script ➔ [Authorize OAuth]
Step 3: Running in Preview Mode
Leave CONFIG.DRYRUN = true. Click Preview at the bottom right of the Scripts console.
Review the Logs tab at the bottom of the screen. The script logs every evaluated campaign, its trailing spend, conversion value, calculated POAS, and whether it met the criteria for a pause. Open your Google Sheet to verify that rows are populating properly with test logs.
Step 4: Scheduling Execution Frequency
Once preview output is verified, set your operational schedule:
1. Click Save in the script interface.
2. In the main Scripts overview list, find your newly created script.
3. Under the Frequency column, select Hourly or Daily.
4. For aggressive budgets spending over $1,000/day, choose Hourly. For mid-tier accounts spending $100–$500/day, running daily at early afternoon (e.g., 2:00 PM or 3:00 PM) allows sufficient morning conversion volume to clear statistical significance.
If manual script maintenance and managing complex spreadsheets pulls focus from broader growth, consider upgrading your tool stack. AdTurbo provides an AI Google Ads manager that monitors multi-tier performance drops across campaigns dynamically, keeping margins protected without manual code reviews.
---
Edge Cases, Mixed Margins, and Safe Reactivation
Automation scripts require practical management guardrails. Without defined processes for edge cases, automated pausing can disrupt learning phases and daily revenue.
Managing Mixed-Margin Products Inside Single Ad Groups
If a single Shopping campaign contains products with 10% margins alongside items with 60% margins, a single blended DEFAULTMARGINCOEFFICIENT can produce inaccurate results. In these situations, avoid setting broad campaign-level scripts. Instead:
1. Re-structure campaigns using Custom Labels (Custom Label 0 = Margin Tier: HighMargin, LowMargin).
2. Segment ad groups by margin tier.
3. Use CONFIG.APPLYTOLEVEL = 'ADGROUP' and define multiple scripts targeting specific campaign names, adjusting the margin coefficient accordingly for each.
To keep your overall cost profile balanced across tiers, our breakdown on why Google Ads is so expensive outlines practical strategies for restructuring product groups around true margins.
When to Unpause Paused Shopping Entities
Never build a script that auto-unpauses campaigns intraday without human review. If a campaign is paused due to poor POAS at 1:00 PM, re-enabling it at 4:00 PM will burn through remaining daily budgets during late-afternoon click inflation.
Establish a manual review cadence:
1. Inspect Conversion Attribution: Check if delayed conversions came in overnight that lift the trailing 24-hour POAS back above the target.
2. Check Merchant Center Feed Health: Confirm whether inventory stockouts, pricing errors, or shipping configuration glitches triggered conversion drops.
3. Remove the Label and Re-enable: Once verified, filter by Label = POASPAUSED, remove the label, and manually switch the entity status back to Enabled.
Campaign Auto-Paused (Script) ➔ POASPAUSED Label Applied ➔ Team Alert Triggered
│
Manual Audit: Check Feeds, Conversion Lag, Stock Status ◀──────────┘
│
Resolve Issues ➔ Remove Label ➔ Manually Enable Campaign
If you find yourself continuously auditing accounts due to bid inefficiencies, read our step-by-step walkthrough on how to manage Google Ads to streamline your ongoing maintenance workflow.
---
Related Guides
• PPC Audit Checklist: 12 Steps to Fix a Leaking Google Ads Account
• Why Is Google Ads So Expensive? 7 Reasons (And How to Pay Less)
• Google Ads Optimization Checklist: 15 Things to Check Every Week
---
Frequently Asked Questions
Will pausing Shopping campaigns reset Smart Bidding machine learning?
Pausing a Shopping campaign for a short window (under 24 hours) does not reset your Smart Bidding learning phase. Google retains historical conversion data up to several weeks, though prolonged pauses exceeding 7 days can push bid strategies back into an exploratory "Learning" status.
Can this POAS script run on Performance Max campaigns?
Yes, but with limitations. You can run the script at the Campaign level to pause entire Performance Max campaigns when trailing POAS collapses, but you cannot pause individual Asset Groups programmatically using standard AdsApp methods at this time.
Why did the script pause a campaign that had a 300% ROAS?
If you configured your margin coefficient to 25% and set your POAS threshold to 1.0, a 300% ROAS yields a POAS of only 0.75 ($300 revenue × 0.25 margin = $75 gross profit on $100 spend). Because the campaign is generating negative cash flow after factoring in your unit costs, the script executed as designed to protect your margin.