Performance Max Script: Simple Setup for Weekly Search-Term Insights
Searching for an easy way to see which queries trigger your Google Ads Performance Max campaigns? Meet the Performance Max Search Term script—a one‑file snippet that drops weekly search‑term insights straight into a Google Sheet without APIs, manual exports, or expensive tools. This guide explains what the script does, why it matters, and how anyone can set it up in under two minutes.
Why the data even matters
Google hides raw search queries for Performance Max. The Performance Max script pulls the next best thing—search‑term categories—then adds week‑over‑week change so you can:
Spot rising demand before competitors;
Kill categories that are tanking;
See which search buckets actually convert;
Uncover brand‑new intent you’re not serving yet.
What the script actually does
✔ Downloads grouped search‑term category labels for your chosen Performance Max campaign.
✔ Fetches metrics for the last 7 days and the previous 7 days.
✔ Calculates impressions, clicks, conversions and percentage change.
✔ Flags brand‑new categories with a NEW tag.
✔ Writes everything into a Google Sheet template that already sorts Trending, Declining, New and Converting searches.
Grab the ready‑made Google Sheet
Click the link below to make your own copy—no editing required. All formulas and views are pre‑built:
👉 [Click here to copy the Performance Max script template]
Quick‑Start Setup (2 minutes)
1. Copy the Sheet – use the link above and save it to your Drive.
2. Open Google Ads → Tools & Settings → Scripts → New Script.
3. Paste the code (full script is at the end of this doc).
4. Change two lines only:
`var CAMPAIGN_ID = YOUR_CAMPAIGN_ID_HERE;` ← your Performance Max campaign ID
var SPREADSHEET_KEY = 'YOUR_SHEET_ID_HERE';` ← the Sheet ID from your copy link
5. Authorise once, hit Run, and watch the Sheet fill up.
6. Click Schedule → Weekly so the report refreshes every Monday.
Reading the Sheet tabs
• raw‑data – master dump; columns A‑H refresh weekly, column I auto‑calculates % change.
• Trending Searches – categories with >50 % growth in impressions, ordered by size.
• Declining Searches – down more than 30 %. Time to tighten creative or budgets.
• New Searches – brand‑new categories the script saw for the first time this week.
• Converting Searches – any category with at least one conversion in the last 7 days.
Smart ways to use these insights
• Creative refresh: build headlines and assets that echo the exact wording in Trending categories.
• Landing‑page ideas: New categories often reveal intent you don’t yet cover on‑site.
Troubleshooting FAQ
Sheet not updating? Make sure the script is authorised and scheduled. Check execution logs for errors.
#DIV/0! in % Change? That row had zero impressions last week—normal. The template hides the error automatically.
Want multiple campaigns? Duplicate the script, or loop an array of campaign IDs inside the code.
Full Performance Max script (copy-paste as is)
/** * Performance Max Search-Term Insight Script * * 1. Copy the Google Sheet template (link in the guide) * 2. Paste this script into Google Ads → Tools & Settings → Scripts * 3. Replace the two placeholders (YOUR_CAMPAIGN_ID_HERE & YOUR_SHEET_ID_HERE) below → Authorise → Run → Schedule */ function main() { /* ── EDIT THESE TWO LINES ONLY ───────────────────────── */ var CAMPAIGN_ID = YOUR_CAMPAIGN_ID_HERE; // e.g. 1234567890 var SPREADSHEET_KEY = 'YOUR_SHEET_ID_HERE'; // the long ID or full URL /* ────────────────────────────────────────────────────── */ var RAW_SHEET = 'raw-data'; /* Date helpers */ var tz = AdsApp.currentAccount().getTimeZone(); function fmt(d){ return Utilities.formatDate(d, tz, 'yyyy-MM-dd'); } var today = new Date(); var endCurr = fmt(new Date(today.setDate(today.getDate() - 1))); // yesterday var startCurr = fmt(new Date(today.setDate(today.getDate() - 6))); // 7-day window var endPrev = fmt(new Date(today.setDate(today.getDate() - 1))); // prior week end var startPrev = fmt(new Date(today.setDate(today.getDate() - 6))); // prior week start /* Open the sheet */ var ss = SPREADSHEET_KEY.indexOf('https://') === 0 ? SpreadsheetApp.openByUrl(SPREADSHEET_KEY) : SpreadsheetApp.openById(SPREADSHEET_KEY); var sh = ss.getSheetByName(RAW_SHEET) || ss.insertSheet(RAW_SHEET); /* Add header the first time */ if (sh.getLastRow() === 0) { sh.appendRow([ 'Category label', 'Impr. last 7d','Impr. prev 7d', 'Clicks last 7d','Clicks prev 7d', 'Conv. last 7d','Conv. prev 7d', 'NEW vs prev week?','% Change' ]); } /* Clear previous values (A-H only). Column I keeps %-change formula. */ var lastRow = sh.getLastRow(); if (lastRow > 1) { sh.getRange(2, 1, lastRow - 1, 8).clearContent(); } /* Make sure % Change formula exists */ if (sh.getRange('I2').getFormula() === '') { sh.getRange('I2') .setFormula('=ARRAYFORMULA(IFERROR((B2:B-C2:C)/C2:C,))'); } /* Helper to pull one date window into a map */ function windowMap(from, to) { var q = 'SELECT campaign_search_term_insight.category_label,' + 'metrics.impressions, metrics.clicks, metrics.conversions ' + 'FROM campaign_search_term_insight ' + 'WHERE campaign_search_term_insight.campaign_id = ' + CAMPAIGN_ID + ' ' + "AND segments.date BETWEEN '" + from + "' AND '" + to + "'"; var map = {}, it = AdsApp.search(q); while (it.hasNext()) { var r = it.next(); map[r.campaignSearchTermInsight.categoryLabel] = { impr: r.metrics.impressions, clicks: r.metrics.clicks, conv: r.metrics.conversions }; } return map; } var cur = windowMap(startCurr, endCurr); var prev = windowMap(startPrev, endPrev); /* Build rows */ var labels = Object.keys(Object.assign({}, cur, prev)); var rows = labels.map(function(lbl) { var c = cur[lbl] || {impr:0, clicks:0, conv:0}; var p = prev[lbl] || {impr:0, clicks:0, conv:0}; return [ lbl, c.impr, p.impr, c.clicks, p.clicks, c.conv, p.conv, prev[lbl] ? '' : 'NEW' ]; }); /* Write data */ if (rows.length) { sh.getRange(2, 1, rows.length, rows[0].length).setValues(rows); } Logger.log('Sheet updated → ' + ss.getUrl()); }
That’s it!
Copy the sheet, paste the Performance Max script, swap the two IDs, and you’ve got a living, breathing search‑intent radar without spreadsheets or APIs. Happy optimizing!
This article was written with the support of A.I. technology.