Skip to content
JavaScript

Streamline Google Ads Reporting with a Free Script for Search and PMax

A Google Ads script merges Search and PMax terms into a single report, simplifying ad performance analysis.

Topic
JavaScript
Reading time
5 min
Length
1,016 words
Published
Oct 12, 2026
03:02 pm IST
In this article
  1. Why This Matters
  2. Using the Google Ads Script
  3. Implementing the Script
  4. Configuration and Settings
  5. What This Doesn't Solve
  6. Code Example
  7. How I Read the Report
  8. Tested Before You Trust It
  9. The Other Scripts in the Repo

If you're in the trenches managing Google Ads accounts, juggling Search, Shopping, and Performance Max campaigns can be downright frustrating, especially during search terms review. Typically, you'd have to switch between different reports since Search and Shopping terms link to ad groups, while Performance Max terms are at the campaign level. This requires exporting both sets, merging them, and manually sorting by cost. Ishant Sharma introduced a handy Google Ads script that simplifies this process, rolling everything into one streamlined procedure. Check it out here.

Why This Matters

Streamlining search term analysis isn't just nice to have; it's crucial for extracting maximum value from your ad budget and improving performance metrics. With this script, you get a unified report compiling search terms from Search, Shopping, and Performance Max campaigns into one tidy package. This helps make quicker, more informed decisions, ideally leading to better budget allocation and more effective campaigns. The script automates data collection and merging, saving time and minimizing those annoying manual errors.

Using the Google Ads Script

The script is free and open source (MIT license), making search term management straightforward. Here’s the lowdown:

  • Data Pulling: The script pulls search terms from Search and Shopping campaigns with ad group context and gathers Performance Max terms at the campaign level. Essentially, it uses two different GAQL queries tailored to each campaign type.
  • Data Merging: After extracting the data, the script merges it and sorts by cost, starting with the highest. This helps address the most expensive terms first.
  • Metrics Calculation: Provides essential metrics like cost, clicks, conversions, conversion value, CPA, and ROAS for each term. Handles conversions for cost from micros to your account currency, ensuring CPA and ROAS calculations avoid misleading zeros.
  • Flagging for Review: Terms get flagged if they exceed certain thresholds without conversions, have a CPA higher than your target, or a ROAS below the target. Consider these flags as cues for potential improvements.
  • Output Options: The top rows are logged, and there's an option to export the entire report as a CSV to Google Drive—perfect for keeping a historical performance record.

Implementing the Script

Here’s how to get the script running:

  • Head to Google Ads, then Tools > Bulk actions > Scripts and create a new script.
  • Copy and paste the full contents of 02-search-term-review.js from GitHub.
  • Review the CONFIG block to set parameters like DATE_RANGE, MIN_COST, and TARGET_CPA to fit your needs. This customization fine-tunes the scope and analysis criteria.
  • Authorize it, click Preview, and check the Logs to ensure everything’s functioning correctly before running it for real.
  • If all looks good, set OUTPUT_TO_DRIVE: true and run it to receive the full CSV report for a detailed view of your search term performance.

The script operates on one account at a time, so for multiple accounts, you'll need to run it individually for each. It doesn’t support manager accounts (MCC), so keep that in mind.

Configuration and Settings

The script offers flexible configuration, letting you customize it to achieve your goals:

  • DATE_RANGE: Defaults to 'LAST_30_DAYS', providing the most current data.
  • MIN_COST and MIN_CLICKS: Establishes a baseline to prevent flagging terms lacking enough exposure, thus reducing false positives.
  • TARGET_CPA and TARGET_ROAS: These settings are left off by default, allowing adaptation to various account dynamics. Knowing your break-even ROAS is key to avoiding targets that might hurt your bottom line.
  • INCLUDE_PMAX: Ensures Performance Max terms are included, unless your script runtime can't support it, stopping with a message. This inclusion is vital if you're relying heavily on Performance Max campaigns.

What This Doesn't Solve

Despite its usefulness, the script isn't a catch-all solution:

  • Manager Account Limitations: It can't be run across multiple accounts within a manager account setup, posing a limitation for agencies or users managing several accounts at once.
  • Data Completeness: Google Ads doesn’t provide every search term, so your reports might miss out on some insights.
  • Decision-Making: The script supplies data, but you're responsible for making decisions. Interpret flags and data with an understanding of your campaigns and objectives.

Code Example

const CONFIG = {
  DATE_RANGE: 'LAST_30_DAYS',
  MIN_COST: 100,      // Account currency
  MIN_CLICKS: 30,
  MIN_CONVERSIONS: 5,
  TARGET_CPA: 0,      // 0 turns this rule off
  TARGET_ROAS: 0,     // e.g. 4 means 4x; 0 turns it off
  MAX_ROWS: 20000,
  LOG_ROWS: 20,
  OUTPUT_TO_DRIVE: false,
  INCLUDE_PMAX: true
};

This code snippet serves as your starting template. Customize these settings to align the script’s output with your specific goals and performance metrics.

How I Read the Report

Extracting useful insights from the report means knowing how to read it effectively. Here's how I do it:

  • Start at the Top: Concentrate on the first 20 rows—they typically indicate where most of your money is going. That's where you can make the biggest impact by addressing high-cost, low-conversion terms.
  • Interpret Flags as Questions: View flagged terms as prompts for further investigation rather than definite problems. A high CPA flag might result from a long sales cycle or differences in conversion tracking.
  • Decide on Fixes: For Search campaigns, consider adding negative keywords or tweaking match types. For Performance Max, think about account-level negatives or refining asset-group signals. The data’s there, but strategy decisions are yours to make.
  • Be Aware of Missing Data: Google Ads won’t show every search term, so manage your expectations regarding report completeness.

Tested Before You Trust It

This script underwent 13 automated tests simulating Google Ads responses, covering key areas like micros conversion, review flags, merging, CSV escaping, and preview export guard. While these tests provide a solid base, be sure to run a Preview in your own environment to verify everything's working correctly.

The Other Scripts in the Repo

The repository has additional scripts that might prove useful:

  • 01-campaign-performance-audit.js: Offers campaign-level cost, conversions, CPA, and ROAS along with similar review flags.
  • 03-shopping-product-performance.js: Provides item-level analysis of Shopping and Performance Max product performance.
  • 04-account-budget-pacing.js: Helps pace your media budget against the calendar month.
  • 05-ad-final-url-checker.js: Checks HTTP status and redirects for every final URL in enabled ads.

If you try out the script, feedback is welcome on GitHub. Suggest improvements or report issues, and contribute to refining tools for everyone in the advertising community.

Sources

See Search and Performance Max search terms in one report with a free Google Ads script

Every claim above was checked against this source before publishing. The analysis, the code and the opinions are mine.

Frequently asked

Can this script be used for manager accounts?

No, the script is designed for individual accounts and cannot be used across multiple accounts in a manager account setup.

What is the primary benefit of using this script?

The script automates the merging and analysis of search terms from different Google Ads campaigns, saving time and reducing manual errors.

How can I customize the script for my needs?

You can adjust the settings in the CONFIG block, such as DATE_RANGE, MIN_COST, and TARGET_CPA, to align with your specific campaign requirements.

Does the script modify any existing Google Ads settings?

No, the script is read-only and does not modify any bids, negatives, or settings in your Google Ads account.

Deepak Kumar

Written by

Deepak Kumar

Sr Software Engineer at India Today Group | Aaj Tak · MERN Stack · Generative AI

I have worked in JavaScript daily for nine years, across browser code that has to stay fast and server code that has to stay up. I write here about what those systems actually do once real traffic hits them. Hiring a JavaScript developer in India? Here is how I work.

Message me