Performance Max placement bleed monitor script
A free, read‑only Google Ads Script that reads where your Performance Max campaigns showed, grades mobile apps, games and foreign‑language sites, and writes them to a Google Sheet. MIT licensed.
Configures the script in this tab. Copy or download the MIT .js file and paste it into Google Ads Scripts. Where your data goes
pmax-
5 KB · 169 lines
- Reads
- performance_max_placement_view
- Writes
- Your Google SheetOptional email
- Changes in Google Ads
- None
- Runs in
- One account
- Suggested frequency
- Weekly
- License
- MIT
/** * Performance Max Placement Bleed Monitor * Read-only Google Ads Script (MIT License) * Copyright (c) 2026 Parallel AI, Inc. * https://www.withparallel.ai * Docs & configurator: * https://www.withparallel.ai/scripts/pmax-placement-bleed-monitor * Repository: * https://github.com/parallel-ai-inc/google-ads-scripts * * Changes in Google Ads: None (reads via AdsApp.search). * Google Ads is a trademark of Google LLC. Parallel AI is * not affiliated with or endorsed by Google. */const CONFIG = { LOOKBACK_DAYS: "LAST_30_DAYS", MIN_IMPRESSIONS: 500, FLAG_MOBILE_APPS: true, SPREADSHEET_URL: "", EMAIL_RECIPIENTS: "",};Lines 23 to 169The script body, the same for every setting
const GAMING_WORDS = [ "game", "puzzle", "solitaire", "word", "blast", "arcade", "casino", "slots", "sudoku", "trivia", "mahjong",];const FOREIGN_WORDS = [ "recetas", "noticias", "nachrichten", "heute", "gratuit", "kostenlos",];const FOREIGN_TLDS = [".de", ".es", ".fr", ".ru", ".br", ".mx"];function main() { const query = [ "SELECT", " campaign.id, campaign.name,", " performance_max_placement_view.placement,", " performance_max_placement_view.display_name,", " performance_max_placement_view.placement_type,", " metrics.impressions", "FROM performance_max_placement_view", "WHERE segments.date DURING " + CONFIG.LOOKBACK_DAYS, " AND metrics.impressions >= " + CONFIG.MIN_IMPRESSIONS, "ORDER BY metrics.impressions DESC", ].join("\n"); const flagged = []; const counts = { GAMING: 0, MOBILE_APP: 0, FOREIGN_LANGUAGE: 0, CORE: 0, }; let totalImpressions = 0; const rows = AdsApp.search(query); while (rows.hasNext()) { const row = rows.next(); const view = row.performanceMaxPlacementView || {}; const placement = String(view.placement || ""); const name = String(view.displayName || placement); const pType = String(view.placementType || "WEBSITE"); const impr = Number((row.metrics || {}).impressions || 0); totalImpressions += impr; const grade = gradePlacement(placement, name, pType); counts[grade] = (counts[grade] || 0) + impr; if (grade !== "CORE") { flagged.push([ row.campaign ? row.campaign.name : "", name, placement, pType, grade, impr, ]); } } const sheet = openOrCreateSheet( CONFIG.SPREADSHEET_URL, "Parallel AI - PMax Placement Bleed" ); writeTab(sheet, "Flagged placements", [ "Campaign", "Display name", "Placement", "Type", "Grade", "Impressions", ], flagged); const summaryRows = Object.keys(counts).map((grade) => { const impr = counts[grade]; const share = totalImpressions > 0 ? ((impr / totalImpressions) * 100).toFixed(1) + "%" : "0.0%"; return [grade, impr, share]; }); writeTab(sheet, "Summary", [ "Grade", "Impressions", "Impression share", ], summaryRows); if (CONFIG.EMAIL_RECIPIENTS && flagged.length > 0) { MailApp.sendEmail( CONFIG.EMAIL_RECIPIENTS, "PMax placement bleed: " + flagged.length + " flagged", "Review impressions-only placement rows in: " + sheet.getUrl() ); } Logger.log("Sheet URL: " + sheet.getUrl());}function hasWord(text, word) { const tokens = text.split(/[^a-z0-9]+/); return tokens.indexOf(word) !== -1;}function extractHost(raw) { let s = String(raw || "").toLowerCase().trim(); if (s.indexOf("mobileapp::") === 0) return ""; s = s.replace(/^https?:\/\//, "").split(/[/?#:]/)[0]; return s;}function hasForeignTld(raw) { const host = extractHost(raw); if (!host) return false; return FOREIGN_TLDS.some((tld) => host.endsWith(tld));}function gradePlacement(placement, name, pType) { const hay = (name + " " + placement).toLowerCase(); if (pType === "GOOGLE_PRODUCTS" || pType === "YOUTUBE_VIDEO" || pType === "YOUTUBE_CHANNEL") { return "CORE"; } if (GAMING_WORDS.some((w) => hasWord(hay, w))) { return "GAMING"; } if (FOREIGN_WORDS.some((w) => hasWord(hay, w)) || hasForeignTld(placement) || hasForeignTld(name)) { return "FOREIGN_LANGUAGE"; } if ( CONFIG.FLAG_MOBILE_APPS && (pType === "MOBILE_APPLICATION" || placement.indexOf("mobileapp::") === 0) ) { return "MOBILE_APP"; } return "CORE";}function safeCell(val) { if (typeof val !== "string") return val; if (/^[=+@]/.test(val) || /^-[^0-9.]/.test(val)) return "'" + val; return val;}function openOrCreateSheet(url, fallbackName) { return url ? SpreadsheetApp.openByUrl(url) : SpreadsheetApp.create(fallbackName);}function writeTab(spreadsheet, name, headers, rows) { let tab = spreadsheet.getSheetByName(name); if (!tab) tab = spreadsheet.insertSheet(name); tab.clearContents(); const safeRows = rows.map((r) => r.map(safeCell)); const data = [headers].concat(safeRows); tab.getRange(1, 1, data.length, headers.length).setValues(data);}Install it in Google Ads
- Set the thresholds on this page, then copy the script or download the .js file.
- In Google Ads, open Tools, then Bulk actions, then Scripts, and add a new script.
- Paste the script over the starter code and give it a name.
- Google Ads asks you to authorize the script the first time. That happens in your own account, under your Google login.
- Choose Preview. Copy the Google Sheet URL from the last log line and paste it into SPREADSHEET_URL so scheduled runs reuse one Sheet instead of creating a new one each time.
- Set its frequency on the Scripts page. Weekly suits this script.
What it reads and the rules it follows
One query on performance_max_placement_view, through AdsApp.search. It asks for each placement’s campaign, name, type and impressions over the lookback window, and nothing else.
- In Google Ads API v26, performance_max_placement_view exposes metrics.impressions with no placement‑level clicks or spend. The script writes impression counts and impression share and never invents placement dollars.OfficialGoogle Ads Help, Find or create placement reports for your Performance Max campaigns (and API v26 performance_max_placement_view)
- The script reads performance_max_placement_view through AdsApp.search() and writes findings to your Google Sheet. Review the sheet before adding account‑level placement exclusions in Content Suitability.Practitioner rule
The Sheet it writes
Two tabs. Flagged placements lists each placement graded as a game, a mobile app or a foreign‑language site, with its impressions. Summary adds up impressions by grade and gives each grade’s share. With an alert email set, Google Ads Scripts sends one from your account when a run flags a placement.
| Campaign | Display name | Placement | Type | Grade | Impressions |
|---|---|---|---|---|---|
| PMax | Roof replacement | Tile Match Mania | mobileapp::2-com.tilematch.mania | MOBILE_APPLICATION | GAMING | 14,280 |
| PMax | Roof replacement | Daily Crossword Puzzle | mobileapp::2-com.dailycrossword.app | MOBILE_APPLICATION | GAMING | 8,640 |
| PMax | Storm repair | Quick QR Scanner | mobileapp::2-com.quickqr.scanner | MOBILE_APPLICATION | MOBILE_APP | 3,420 |
| PMax | Roof replacement | noticias-hoy.example | noticias-hoy.example | WEBSITE | FOREIGN_LANGUAGE | 1,890 |
What it cannot tell you
- Google reports impressions for a Performance Max placement and no clicks or cost, so the Sheet holds impressions and no spend.
- Grades come from two word lists in the script. A game is a name holding a word such as puzzle or casino. A foreign‑language site is a name holding a word such as noticias or a country domain such as .de. Edit both lists to fit the account.
- Placements on Google’s own properties and on YouTube are graded core and stay off the flagged tab.
- It excludes nothing. A placement exclusion for Performance Max is a separate step, set at the account level.
- Each run clears both tabs and writes the latest window, so the Sheet holds one run at a time.
Where your data goes
This page builds the script’s text in your browser tab. It asks for no login and connects to no Google Ads account.
A Sheet address or an alert email you type goes into the script’s text, so the copy is ready to paste. The link you copy holds thresholds and switches only, in the part of the address after the # sign, which a browser does not send when it requests a page.
Once pasted, the script runs inside Google Ads Scripts under your Google account. It reads the account, writes to your Google Sheet and sends the optional email from your account. Nothing in it calls Parallel AI.
Site analytics are separate from the script. If you accepted analytics cookies, they record how pages on this site are used, which can include what is on the screen. The privacy policy covers site analytics and your consent settings.
On a live account
A script writes the same table on every run. Parallel AI is the AI agent platform for Google Ads. A Google Ads AI agent reads Performance Max placements, search terms and asset groups from every connected account, works out what the waste costs, and adds the exclusions.
Questions and answers
Is the script free?
Yes. It is open source under the MIT license, with no login, no trial and no email address. The whole file is on this page and on GitHub.
Does the script change anything in Google Ads?
No. It reads with AdsApp.search and writes to a Google Sheet. It has no call that changes a bid, a budget, a placement or a status.
Can a script see cost by placement in Performance Max?
No. Google reports impressions for each Performance Max placement and no cost or clicks. The script writes impressions and each grade’s share of them.
How are placements excluded from Performance Max?
Placement exclusions for Performance Max are set at the account level, in Google Ads. The script lists the placements and leaves the exclusion to you.
Does the script need access to my Google account?
Google Ads asks you to authorize the script the first time it runs. That grant is between you and Google, inside your own account. Parallel AI receives nothing.
How often should it run?
Weekly suits most accounts. Set the frequency on the Scripts page in Google Ads.
Google Ads is a trademark of Google LLC. Parallel AI is not affiliated with or endorsed by Google.
Clear Performance Max waste on the live account
Connect Google Ads and Parallel AI reads placements, search terms and asset groups across your connected accounts, and writes the findings to a Doc.
Starter $20, Pro $60 and Max $200 a month
You add a card to start the trial, then connect Google Ads.