Whale Traffic

Tools01 Wasted search terms

Find the search terms that only cost you money.

This script reads your search terms report, adds each term up across campaigns, and lists the ones that spent over your threshold without a single conversion. It also tells you what share of your search term spend they took.

Get the script

Free Google Ads script · Reads only

What it reports

What you get back.

Best run · Weekly

  1. 01

    Every search term at or above your spend threshold with zero conversions.

  2. 02

    Cost, clicks, and impressions for each term, and the campaigns it ran in.

  3. 03

    The total wasted and its share of the search term spend the script read.

The script.

Copy all of it into a new script in Google Ads. The settings sit in the first few lines.

wasted-search-terms.js · 103 lines

const CONFIG = {
  DAYS: 30,
  MIN_COST: 20,
  MAX_ROWS: 20000,
  SHEET_URL: "",
  EMAIL: "",
};

function main() {
  const account = AdsApp.currentAccount();
  const currency = account.getCurrencyCode();
  const range = dateRange(CONFIG.DAYS, account.getTimeZone());
  const rows = AdsApp.search(
    "SELECT search_term_view.search_term, campaign.name, metrics.cost_micros, metrics.clicks, metrics.impressions, metrics.conversions " +
      "FROM search_term_view " +
      "WHERE segments.date BETWEEN '" + range.start + "' AND '" + range.end + "' AND metrics.clicks > 0 " +
      "ORDER BY metrics.cost_micros DESC LIMIT " + CONFIG.MAX_ROWS
  );

  const terms = new Map();
  let read = 0;
  let totalCost = 0;
  while (rows.hasNext()) {
    const row = rows.next();
    const text = row.searchTermView.searchTerm;
    const cost = Number(row.metrics.costMicros) / 1e6;
    if (!terms.has(text)) {
      terms.set(text, { cost: 0, clicks: 0, impressions: 0, conversions: 0, campaigns: new Set() });
    }
    const term = terms.get(text);
    term.cost += cost;
    term.clicks += Number(row.metrics.clicks);
    term.impressions += Number(row.metrics.impressions);
    term.conversions += Number(row.metrics.conversions);
    term.campaigns.add(row.campaign.name);
    totalCost += cost;
    read++;
  }

  const wasted = Array.from(terms.entries())
    .filter((entry) => entry[1].conversions === 0 && entry[1].cost >= CONFIG.MIN_COST)
    .sort((a, b) => b[1].cost - a[1].cost);
  const wastedCost = wasted.reduce((sum, entry) => sum + entry[1].cost, 0);

  const summary = [
    account.getName() + ", " + range.start + " to " + range.end,
    wasted.length + " search terms spent " + money(wastedCost, currency) + " with no conversions.",
    "That is " + percent(wastedCost, totalCost) + " of the " + money(totalCost, currency) + " of search term spend read.",
  ];
  if (read >= CONFIG.MAX_ROWS) {
    summary.push("Stopped at " + CONFIG.MAX_ROWS + " rows. Raise MAX_ROWS to read the rest.");
  }

  const table = [["Search term", "Cost", "Clicks", "Impressions", "Campaigns"]].concat(
    wasted.map((entry) => [
      entry[0],
      round(entry[1].cost),
      entry[1].clicks,
      entry[1].impressions,
      Array.from(entry[1].campaigns).join(", "),
    ])
  );
  const top = table.slice(1, 21).map((line) => money(line[1], currency) + "  " + line[0]);

  summary.concat([""], top).forEach((line) => Logger.log(line));
  writeSheet(CONFIG.SHEET_URL, "Wasted search terms", table);
  sendMail(CONFIG.EMAIL, "Wasted search terms: " + account.getName(), summary.concat([""], top));
}

function dateRange(days, timeZone) {
  const day = 24 * 60 * 60 * 1000;
  const end = new Date(Date.now() - day);
  const start = new Date(end.getTime() - (days - 1) * day);
  return {
    start: Utilities.formatDate(start, timeZone, "yyyy-MM-dd"),
    end: Utilities.formatDate(end, timeZone, "yyyy-MM-dd"),
  };
}

function round(value) {
  return Math.round(value * 100) / 100;
}

function money(value, currency) {
  return currency + " " + round(value).toFixed(2);
}

function percent(part, whole) {
  return whole > 0 ? Math.round((part / whole) * 100) + "%" : "0%";
}

function writeSheet(url, tabName, table) {
  if (!url) return;
  const book = SpreadsheetApp.openByUrl(url);
  const sheet = book.getSheetByName(tabName) || book.insertSheet(tabName);
  sheet.clearContents();
  sheet.getRange(1, 1, table.length, table[0].length).setValues(table);
}

function sendMail(to, subject, lines) {
  if (!to) return;
  MailApp.sendEmail(to, subject, lines.join("\n"));
}

Settings

DAYSStarts at 30
How many days to look back, ending yesterday.
MIN_COSTStarts at 20
The smallest spend, in your account currency, before a term is listed.
MAX_ROWSStarts at 20000
The most report rows to read. The script tells you if it stops here.
SHEET_URLStarts empty
A Google Sheet link to write the full list to. Leave it empty to skip.
EMAILStarts empty
Where to send the summary. Leave it empty to skip.

How to install

  1. 01

    Open Scripts

    In Google Ads, open Tools, then Bulk actions, then Scripts.

  2. 02

    Paste it in

    Press the plus button, choose New script, and paste the script over the sample code.

  3. 03

    Set the values

    Edit the settings at the top. Add a Google Sheet link or an email address if you want the report sent somewhere.

  4. 04

    Preview, then schedule

    Authorize the script, press Preview to read the report in the log, then save it and choose how often it runs.

Good to know

  • A term with no conversions in 30 days is a candidate, not a verdict. Low-volume accounts convert rarely, so read the list before you add negatives.
  • It reads Search campaigns. Performance Max search terms are not in this report.
  • Google hides low-volume search terms, so the totals cover only the terms it shows.

Free to use and to change. The script only reads your account. It is provided as it is, with no warranty, so run Preview before you schedule it.

Work with us

Tell us what you’re trying to grow.

Start with a quick conversation about your goals and current spend. We’ll come back with a plan and a straight answer on whether we’re the right fit.

Request a proposal