Whale Traffic

Tools02 Wasted words

One bad word, hiding in a hundred search terms.

A single search term rarely spends enough to stand out. The word it shares with fifty others does. This script splits every search term into words and two-word phrases, totals the cost behind each, and lists the ones that never converted.

Get the script

Free Google Ads script · Reads only

What it reports

What you get back.

Best run · Monthly

  1. 01

    Every word or phrase with no conversions across three or more search terms.

  2. 02

    The cost and clicks behind it, and how many search terms contain it.

  3. 03

    Sorted by cost, so the strongest negative keyword candidates come first.

The script.

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

wasted-words.js · 107 lines

const CONFIG = {
  DAYS: 30,
  MIN_COST: 30,
  MIN_TERMS: 3,
  MAX_WORDS: 2,
  MAX_ROWS: 20000,
  IGNORE: ["a", "an", "the", "to", "of", "in", "on", "for", "and", "is", "with", "my", "i", "you", "it", "at", "by", "or"],
  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, metrics.cost_micros, metrics.clicks, 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;
  while (rows.hasNext()) {
    const row = rows.next();
    const text = row.searchTermView.searchTerm.toLowerCase();
    if (!terms.has(text)) terms.set(text, { cost: 0, clicks: 0, conversions: 0 });
    const term = terms.get(text);
    term.cost += Number(row.metrics.costMicros) / 1e6;
    term.clicks += Number(row.metrics.clicks);
    term.conversions += Number(row.metrics.conversions);
    read++;
  }

  const ignore = new Set(CONFIG.IGNORE);
  const phrases = new Map();
  terms.forEach((term, text) => {
    const words = text.split(/\s+/).filter(Boolean);
    const seen = new Set();
    for (let size = 1; size <= CONFIG.MAX_WORDS; size++) {
      for (let i = 0; i + size <= words.length; i++) {
        const phrase = words.slice(i, i + size).join(" ");
        if (size === 1 && ignore.has(phrase)) continue;
        seen.add(phrase);
      }
    }
    seen.forEach((phrase) => {
      if (!phrases.has(phrase)) phrases.set(phrase, { cost: 0, clicks: 0, conversions: 0, terms: 0 });
      const total = phrases.get(phrase);
      total.cost += term.cost;
      total.clicks += term.clicks;
      total.conversions += term.conversions;
      total.terms++;
    });
  });

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

  const summary = [
    account.getName() + ", " + range.start + " to " + range.end,
    wasted.length + " words or phrases never converted, across the " + terms.size + " search terms read.",
  ];
  if (read >= CONFIG.MAX_ROWS) {
    summary.push("Stopped at " + CONFIG.MAX_ROWS + " rows. Raise MAX_ROWS to read the rest.");
  }

  const table = [["Word or phrase", "Cost", "Clicks", "Search terms"]].concat(
    wasted.map((entry) => [entry[0], round(entry[1].cost), entry[1].clicks, entry[1].terms])
  );
  const top = table
    .slice(1, 21)
    .map((line) => currency + " " + line[1].toFixed(2) + "  " + line[0] + "  (" + line[3] + " search terms)");

  summary.concat([""], top).forEach((line) => Logger.log(line));
  writeSheet(CONFIG.SHEET_URL, "Wasted words", table);
  sendMail(CONFIG.EMAIL, "Wasted words: " + 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 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 30
The smallest combined spend before a word is listed.
MIN_TERMSStarts at 3
The fewest search terms a word must appear in.
MAX_WORDSStarts at 2
The longest phrase to count, in words.
MAX_ROWSStarts at 20000
The most report rows to read. The script tells you if it stops here.
IGNOREStarts at 18 words
Common single words to skip, such as “the” and “for”.
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

  • Check each word against the search terms it came from before you block it. A word can be wasteful in one phrase and essential in another.
  • It reads Search campaigns only.
  • Run it over a longer window on small accounts, so each word has enough clicks behind it.

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