How to Use Google Ads Scripts to Get More Control Over Performance Max
Performance Max campaigns are powerful. They also feel like a black box. You hand Google your budget, your assets, and your conversion…
How to Use Google Ads Scripts to Get More Control Over Performance Max
Performance Max campaigns are powerful. They also feel like a black box. You hand Google your budget, your assets, and your conversion goals, and in exchange you get very limited visibility into what is actually happening inside the campaign.
Scripts will not give you back full control. But they give you something valuable: automated reporting, budget monitoring, and organization at scale, without needing to check your account manually every day.
Here is what Google Ads scripts can and cannot do with PMax, and how to set one up properly.

What Google Ads Scripts Actually Are
Scripts are JavaScript snippets that run inside your Google Ads account to automate tasks, pull data, and make changes without manual intervention. Common use cases include generating reports, pausing or enabling campaigns based on performance thresholds, adjusting budgets dynamically, applying labels for organization, and pushing data to Google Sheets or sending email alerts.
They live under Tools & Settings, then Bulk Actions, then Scripts. You can install them at the individual account level, or at the MCC level if you manage multiple client accounts and want to apply the same logic across all of them.
Scripts were originally built for legacy campaign types: Search, Display, and Shopping. Performance Max support has expanded over time, but plenty of standard scripts still will not work correctly unless you specifically write them to recognize the PERFORMANCE_MAX campaign type.
Can You Actually Apply Scripts to PMax?
Yes, with real limitations worth understanding before you invest time building anything.
What currently works:
- Reading campaign-level data: cost, conversions, impressions
- Writing labels and organizing campaigns
- Pausing or enabling entire PMax campaigns
- Monitoring budget pacing and daily spend
- Creating PMax campaigns, using the newer mutate function
- Accessing asset groups, with limited operations
- Exporting performance data to Google Sheets
- Running scripts across MCC accounts for multi-client management
What still does not work:
- Modifying individual creative assets: headlines, descriptions, images
- Accessing detailed placement data, meaning where your ads actually appeared
- Overriding Smart Bidding strategies
- Using traditional AdsApp methods to create campaigns, you need the mutate function for that
The practical takeaway: scripts are genuinely useful for monitoring, reporting, and organization. They are not a workaround for PMax’s core limitation, which is restricted visibility and control over creative and bidding decisions. Google built PMax to automate those things, and scripts were not designed to override that.
Getting Your Account Ready First
Before installing anything, a few prerequisites matter.
You need Admin or Standard access in the account. If you hit an “insufficient permissions” error, that is almost always the cause. Decide whether you are working at the individual account level or the MCC level, since agencies managing multiple PMax campaigns across clients benefit significantly from MCC-level scripts that apply consistent logic everywhere at once.
If your script pushes data to Google Sheets, make sure you are signed into the same Google account across both platforms, pre-create the spreadsheet, and have the URL ready before you start. The first time you run a script, Google will prompt you to authorize access to manage campaigns and connect to any third-party tools like Sheets or Gmail. Skipping that authorization step is the single most common reason a script silently fails to run.
One more detail worth knowing: each script execution has a 30-minute limit, and you can schedule runs hourly, daily, or weekly depending on the task. Budget alerts benefit from hourly checks. Standard reporting is usually fine running once a day.
Installing Your First Script
The process is straightforward once the prerequisites are handled.
Go to Tools & Settings, then Bulk Actions, then Scripts. Click the blue plus button to open the script editor. Paste in your code. Here is a simple example that logs impressions for every PMax campaign in the account:
javascript
function main() {
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
while (campaigns.hasNext()) {
var campaign = campaigns.next();
Logger.log("Campaign: " + campaign.getName() +
" | Impressions: " + campaign.getStatsFor("LAST_7_DAYS").getImpressions());
}
}
Click Authorize and follow the prompts. Before running anything live, always click Preview first. This shows you exactly what the script will read or change without actually executing anything, which is the easiest way to catch a mistake before it affects a live campaign. Once the preview looks clean, run it manually or set a recurring schedule.
Three Scripts Worth Setting Up
Exporting performance data to Sheets gives you an ongoing record of cost, conversions, and CPA across your PMax campaigns without manually pulling reports each week.
javascript
function main() {
var sheetUrl = "PASTE_YOUR_SHEET_URL_HERE";
var sheet = SpreadsheetApp.openByUrl(sheetUrl).getSheetByName("PMax Report");
sheet.clearContents();
sheet.appendRow(["Campaign Name", "Cost", "Conversions", "CPA"]);
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
while (campaigns.hasNext()) {
var c = campaigns.next();
var stats = c.getStatsFor("LAST_7_DAYS");
var cost = stats.getCost();
var conv = stats.getConversions();
var cpa = conv > 0 ? (cost / conv) : 0;
sheet.appendRow([c.getName(), cost, conv, cpa]);
}
}
A budget overspend alert flags any campaign that blew past a threshold the day before, which is useful for catching pacing problems before they compound across a week.
javascript
function main() {
var threshold = 100;
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
while (campaigns.hasNext()) {
var c = campaigns.next();
var cost = c.getStatsFor("YESTERDAY").getCost();
if (cost > threshold) {
Logger.log("Warning: " + c.getName() + " spent $" + cost + " yesterday");
}
}
}
Auto-labeling all PMax campaigns makes every other script and bulk action easier down the line, since you can filter by label instead of rewriting the same condition everywhere.
javascript
function main() {
var labelName = "PMax";
if (!AdsApp.labels().withCondition("Name = '" + labelName + "'").get().hasNext()) {
AdsApp.createLabel(labelName);
}
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
while (campaigns.hasNext()) {
var c = campaigns.next();
if (!c.labels().withCondition("Name = '" + labelName + "'").get().hasNext()) {
c.applyLabel(labelName);
}
}
}
Combined, these three give you a reasonably complete monitoring system: labeled campaigns, budget alerts, and a running performance record, without touching anything Google restricts.
Scaling This Across Multiple Accounts
If you manage several client accounts, MCC-level scripts let you apply the same logic everywhere at once rather than repeating setup account by account.
javascript
function main() {
var accountSelector = MccApp.accounts();
accountSelector.executeInParallel("processClientAccount", "logResults");
}
function processClientAccount() {
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
// Your logic here
}
Labels are worth layering into this at scale too. Something like “PMax-Test” for experimental campaigns or “PMax-HighBudget” for anything spending over a certain threshold lets you build conditional logic that treats different campaign types differently, without maintaining separate scripts for each.
Always wrap operations in error handling, especially anything touching live campaign settings:
javascript
function safeOperation() {
try {
var campaigns = AdsApp.campaigns()
.withCondition("AdvertisingChannelType = 'PERFORMANCE_MAX'")
.get();
// operations here
} catch (error) {
Logger.log("Error: " + error.message);
MailApp.sendEmail({
to: "admin@yourcompany.com",
subject: "PMax Script Error",
body: "Error: " + error.message
});
}
}
Where Scripts Hit a Wall
A few limitations are worth internalizing so you do not waste time building something that was never going to work.
Individual creative assets, headlines, descriptions, images, video, remain completely inaccessible to scripts. If you need to manage creative rotation or testing, that has to happen through the interface or a feed-based approach, not through scripts.
Smart Bidding is another hard boundary. Scripts can monitor and report on bidding performance, but they cannot adjust Target CPA, override Max Conversion Value, or otherwise touch the bidding logic PMax runs on. And placement-level control, meaning blocking specific sites or limiting exposure to certain networks like YouTube or Gmail, simply is not available through scripts either. That has to be handled through account-level settings during setup.
The broader principle: scripts work best for monitoring, alerting, and organizing. They were never meant to replace the manual, granular control that PMax intentionally abstracts away.
Common Errors and Quick Fixes
If a script throws “Cannot Access Asset Group” or similar, it is usually trying to reach ad-group or asset-level data that PMax does not expose to scripts. Stick to campaign-level filtering only.
If a script runs but returns nothing, double-check that your filters actually match active campaigns, and confirm you are not accidentally excluding everything through overly strict conditions. Authorization errors almost always mean you skipped the OAuth prompt or are logged into the wrong Google account relative to your Sheets or Gmail integration.
Data that looks incomplete or oddly low is often a timing issue. Avoid pulling stats for “TODAY” early in the day, since PMax data needs 24 to 48 hours to settle. “YESTERDAY” or “LAST_7_DAYS” are safer, more stable timeframes to build logic around.
The Bottom Line
Performance Max trades visibility and control for automation and reach. Scripts do not undo that trade-off, but they let you build a monitoring layer on top of it: tracking spend, flagging anomalies, organizing campaigns, and exporting data automatically, all without manually checking your account every day.
Use scripts as your eyes and ears, not your hands. Let PMax’s automation do what it was built to do, and build scripts around watching it carefully rather than trying to override it.
Read the full step-by-step guide to Google Ads scripts for PMax here: https://discovermybusiness.co/google-ads-script-setup-for-pmax/
메타데이터
- post_id
- e99fb7eef332
- slug
- how-to-use-google-ads-scripts-to-get-more-control-over-performance-max-e99fb7eef332
- url
- https://medium.com/@areeba_1512/how-to-use-google-ads-scripts-to-get-more-control-over-performance-max-e99fb7eef332
- canonical_url
- https://medium.com/@areeba_1512/how-to-use-google-ads-scripts-to-get-more-control-over-performance-max-e99fb7eef332
- author_url
- https://medium.com/@areeba_1512
- status
- ok
- fetched_at
- 2026-08-08 14:42:09