Blog Playbooks

N-Gram Analysis for Google Ads — No Scripts Needed (2026)

N-gram analysis breaks your search terms into word patterns so wasted spend that hides across hundreds of individual queries becomes visible in one table. Here's how to run it in 2026 — with a script, with a spreadsheet, or with a free browser tool — and the one guardrail that keeps it from costing you conversions.

N-gram analysis breaks every search term in your account into short word sequences — 1-word, 2-word, 3-word “grams” — and rolls each term’s cost, clicks, and conversions up into every gram it contains. Instead of scrolling through 4,000 individual search terms, you look at a few hundred word patterns and immediately see that queries containing “free” spent $570 with almost nothing to show for it.

For years the standard way to do this was a Google Ads script: paste a few hundred lines of JavaScript into your account, authorize it, schedule it, and read the output in a spreadsheet. Scripts still work. But in 2026 you don’t need one — you can get the same table by pasting a CSV into a free browser-based n-gram analyzer that never uploads your data anywhere, or skip the export entirely with a tool connected to your account.

This guide covers all of it: what n-gram analysis actually is, the classic ways to run it (scripts, spreadsheets, specialist tools — with honest pros and cons), a genuine step-by-step manual method, and the guardrail almost every tutorial skips — the one that stops you from blocking words that appear in your converting searches.

What is n-gram analysis?

An n-gram is a sequence of n consecutive words. In the search term “free crm software”:

  • 1-grams (unigrams): free, crm, software
  • 2-grams (bigrams): free crm, crm software
  • 3-grams (trigrams): free crm software

N-gram analysis takes every search term in your account, extracts its grams, and sums each term’s metrics into every gram it contains. The result is a table of word patterns ranked by cost, each carrying total clicks, conversions, and cost across every query it appeared in.

Why single search terms hide what grams expose

The search terms report shows you one query at a time. Waste rarely arrives one query at a time — it arrives as a theme, spread thin across dozens or hundreds of long-tail variations that individually never look bad enough to act on.

Take a small, simplified example — a CRM software advertiser’s search terms over 30 days:

Search term Clicks Cost Conversions
free crm software 120 $240.50 0
crm software pricing 85 $190.00 4
best crm for small business 60 $150.00 3
crm software free trial 70 $140.00 2
free crm for startups 65 $130.00 0
crm software reviews 50 $120.00 1
cheap crm software 55 $110.00 0
salesforce crm pricing 25 $95.00 2
crm software jobs 40 $88.00 0
crm software demo 35 $70.00 1
hubspot crm free 45 $60.00 0
what is crm software 30 $45.00 0

Scanning that list term by term, “crm software jobs” at $88 might not clear your action threshold, and “hubspot crm free” at $60 definitely doesn’t. Now roll the same data up into 1-grams:

1-gram Terms Clicks Cost Conversions
free 4 300 $570.50 2
cheap 1 55 $110.00 0
jobs 1 40 $88.00 0
pricing 2 110 $285.00 6

Suddenly the story is obvious. “Free” is your biggest cost pattern by far. “Jobs” is job seekers, not buyers — pure waste. “Cheap” spent $110 and converted nothing. Meanwhile “pricing” is your best word: $285 for 6 conversions. None of this is visible in the term-by-term view; all of it is visible in a four-row gram table.

That’s the entire pitch for n-gram analysis. The only real question is how you produce that table — and what you’re allowed to do with it (more on that second part in the guardrail section, because the “free” row above is a trap).

The classic ways to run n-gram analysis

1. Google Ads scripts

The traditional method. You paste an n-gram script into Tools → Bulk actions → Scripts, authorize it against your account, and it writes a gram-by-gram breakdown into a Google Sheet, usually on a schedule.

Honest pros:

  • Free, if your time is free.
  • Runs inside your account on a schedule — no exports, always fresh.
  • Full control: if you can read JavaScript, you can change the logic.
  • Good maintained versions exist. Specialists like PEMAVOR and Nils Rooijmans have published solid n-gram scripts for years, and the classic Brainlabs script has been forked endlessly.

Honest cons:

  • Permissions. A script runs with authorization to act on your ad account. You’re pasting a few hundred lines of code — often found on a blog, sometimes lightly modified from a fork of a fork — into a surface that can spend your money. Most published n-gram scripts are read-only and reputable authors are careful, but you are the one who has to read the code and verify that, every time you update it.
  • Maintenance. Scripts break when Google changes report columns, query language fields, or the scripts runtime itself. When that happens, you’re debugging JavaScript at 9am instead of managing campaigns. If you got the script from a blog post, you’re waiting for the author to publish a fix.
  • Coverage. Script-based reports are built on the search terms Google exposes to the API — which means Performance Max activity is mostly invisible to them. If PMax is a meaningful share of your spend, the script sees a fraction of your queries. (Seeing PMax search terms at all is its own topic — we wrote up how to actually see PMax search terms.)
  • Output is analysis, not action. The script ends with a spreadsheet. You still have to decide what to block, hand-build the negative keyword lists, and apply them — the most error-prone part of the whole workflow is still manual.

If you’re comfortable with code, scripts remain a perfectly good answer. The rest of this guide is for everyone who’d rather not be a part-time JavaScript maintainer.

2. Spreadsheets and pivot tables

Export the search terms report, split the terms into words, and roll up cost per word with formulas or a pivot table. Free, transparent, and genuinely educational — you’ll understand your query mix better after doing it once by hand. It gets painful past 1-grams and past a few thousand terms. Full walkthrough in the next section.

3. Specialist web tools

Several PPC tool vendors offer n-gram analyzers where you upload or paste your search terms export. Quality varies from excellent to abandoned. One thing worth checking before you use any of them: where does your data go? A search terms report is competitive data — your queries, your costs, your conversion counts. If the tool processes it server-side, you’re trusting a third party’s storage and logs. Prefer tools that state clearly how the data is processed. (Ours runs entirely in your browser — nothing is uploaded. More below.)

Step-by-step: the manual spreadsheet method

If you want to genuinely understand the mechanics — or you just don’t want another tool — here’s the real recipe in Google Sheets.

Step 1 — Export the report. In Google Ads: Insights & reports → Search terms. Set the date range to 30–90 days (long enough for patterns, short enough to be current). Download as CSV.

Step 2 — Clean the sheet. Open it in Sheets. Keep the columns you need: Search term, Clicks, Impressions, Cost, Conversions. Delete the “Total” rows at the bottom — they’ll poison every rollup if you leave them in.

Step 3 — Build the word list. In a new tab, extract every word from every term:

=ARRAYFORMULA(TRIM(FLATTEN(SPLIT(LOWER(Data!A2:A2000)," "))))

Then dedupe it: wrap the result in UNIQUE(...), or point UNIQUE() at the output column. This is your 1-gram list.

Step 4 — Roll up cost per word. Here’s where most tutorials get it wrong. A naive SUMIF with SEARCH("free", ...) also matches “freelance” and “freeze” — substring matching, not word matching. Pad both sides with spaces to enforce word boundaries. With your word in A2 and the data tab holding terms in column A and cost in column D:

=SUMPRODUCT(
  ISNUMBER(SEARCH(" "&$A2&" ", " "&LOWER(Data!$A$2:$A$2000)&" "))
  * Data!$D$2:$D$2000
)

Copy the same pattern for clicks and conversions (swap the metric column). Drag down the word list.

Step 5 — Sort and filter. Sort by cost descending. Filter to conversions = 0. That’s your waste-pattern shortlist.

Two honest caveats about what you just built:

  • The columns won’t sum to your account totals — and that’s correct. A term containing three distinct words contributes its full cost to three gram rows. Gram tables are for ranking patterns, not accounting.
  • 2-grams are where spreadsheets run out. Generating every adjacent word pair, deduping them, and rolling up with position-aware matching is miserable in formulas. This is exactly the point where people historically gave up and went looking for a script.

The guardrail everyone skips: converting terms

This is the part most n-gram tutorials leave out, and it’s the part that separates “found $500 of waste” from “quietly killed my best trial-signup queries.”

Never add a word as a negative if it appears in search terms that convert.

Look back at the example table. The 1-gram view says:

free — 4 terms, $570.50, 2 conversions

The reflex is: “free” means freebie hunters, block it. But drill into the four terms behind that row:

Search term Cost Conversions
free crm software $240.50 0
free crm for startups $130.00 0
hubspot crm free $60.00 0
crm software free trial $140.00 2

“Crm software free trial” is a buying query — someone looking for exactly what this advertiser sells. A phrase-match negative on free blocks every future query containing the word “free”, including that one. You’d save about $430 of waste and silently amputate a converting query pattern, and nothing in your account would ever tell you it happened. Zero-conversion waste is loud; blocked converting traffic is invisible.

The correct move in this example is one step more precise: block the 2-gram free crm instead. It appears only in “free crm software” and “free crm for startups” — $370.50, zero conversions — and it doesn’t touch “crm software free trial” or “hubspot crm free”. Tighter gram, same waste captured, no collateral damage.

So the working rules are:

  1. Before you block any gram, look at every term behind it. If any of those terms convert, don’t block the gram — find a tighter one (usually a 2-gram) that isolates the waste.
  2. Check the gram against your own keywords. A phrase negative containing a word that’s in one of your enabled keywords can block your own live traffic. If you bid on “crm software pricing”, a negative on pricing is self-sabotage.
  3. When a pattern converts but expensively, that’s a review item, not a block. A word with a CPA three times your average deserves a look — maybe tighter bids, maybe a dedicated ad group — but blocking it deletes its conversions along with its cost.

This guardrail is built into how Keyword Ninja classifies n-grams, and it’s why our AI theme suggestions have two separate buckets: wasteful (zero conversions across multiple terms, no collision with any enabled keyword — safe to block) and expensive (converts, but at ≥3× your average CPA — flagged for human review, never labeled safe). The “safe to block” list is computed from your data, with a hard rule that a converting gram or a gram matching a live keyword can never land in it. If you’re doing this manually, you are that rule — apply it every time.

The no-script shortcuts

The free one: paste a CSV into your browser

We built a free n-gram analyzer that runs the whole analysis client-side:

  • Paste your search terms export — CSV or a straight copy-paste from Excel/Sheets (it detects tab-separated data). It finds the header row and auto-maps the Search term / Clicks / Impressions / Cost / Conversions columns; you can remap manually if your export is unusual.
  • 1-, 2-, and 3-word grams, computed instantly, with clicks, cost, conversions, and CPA per gram.
  • Worst-first sorting: zero-conversion grams ranked by cost on top — your action list, in order.
  • Nothing leaves your browser. The parsing and the math run as JavaScript on your machine. Your report is never uploaded to us or anyone else — you can load the page, turn off your Wi-Fi, and it still works.

No signup, no cost. If you do n-gram analysis quarterly on one account, this plus the guardrail above is honestly all you need. The example tables in this article use the tool’s built-in sample data, so you can load the sample and reproduce every number.

The connected one: n-gram analysis on your live account

The free tool has the same limits every export-based method has: it sees one CSV at a time, it goes stale the moment you download it, and when you’ve found a bad gram, you still have to go build negatives by hand. The in-product version — part of our search term analysis suite — exists to close those gaps. Being honest about what the paid version adds:

  • Live, synced data — no exports. It runs on the search terms already synced from your account, across every account you’ve connected, with whatever date window you want. Agencies can see a waste pattern across a whole client portfolio in one table.
  • Drill-down. Click any gram and see every underlying search term with its own metrics — the guardrail check from the previous section, one click deep, with converting terms visible before you act.
  • One-click negatives. Add a gram as a phrase negative at campaign or ad-group level directly from the table. The analysis and the action live in the same screen — no list-building in spreadsheets.
  • Converting-term protection, enforced by the software. The wasteful/expensive split described above, plus the live-keyword guard that refuses to suggest a gram that matches one of your enabled keywords. The guardrail isn’t a best practice you have to remember; it’s a precondition the suggestions can’t skip.
  • Word-order-agnostic matching. Beyond contiguous grams, an “any order” mode surfaces patterns where the words appear reordered or non-adjacently — useful for long queries and for languages with flexible word order.

The n-gram screen sits alongside Search Terms Ninja, our term-by-term review flow — grams tell you which patterns to hunt, the deck lets you sweep the individual terms. The free browser tool costs $0 forever; the connected n-gram suite is part of the Pro plan at $149/month. If you just want to know whether the analysis would find anything in your account, the free audit will tell you before you pay for anything.

Acting on the results: match types and mechanics

Finding a bad gram is half the job. Blocking it correctly is the other half, and negative keyword mechanics have a few sharp edges:

Word-level blocking = phrase negatives. A one-word phrase-match negative like jobs blocks any query containing the word “jobs” anywhere in it — “crm software jobs”, “jobs at crm companies”, all of it. This is the standard way to act on a 1-gram. (For a single word, a broad negative behaves the same in practice; for multi-word negatives, phrase requires the words adjacent and in order, broad requires all words present in any order.)

Exact negatives are for queries, not patterns. An exact-match negative blocks only that literal query. Use it when one specific search term is the problem, not when a word pattern is.

Negatives don’t do close variants. This surprises everyone: positive keywords match plurals, misspellings, and variants automatically — negatives don’t. Blocking job does not block “jobs”. If your gram table shows both, block both. Same for common misspellings with real spend.

Match the negative to the gram, and prefer the tightest gram that captures the spend. If the 2-gram free crm accounts for most of the 1-gram free’s wasted cost, block the 2-gram as a phrase negative and leave the 1-gram alone. It’s a strictly safer negative with nearly the same savings. (Keyword Ninja’s theme suggestions apply this automatically — a broad 1-gram is dropped when a specific 2-gram already covers the majority of its cost.)

Choose the level deliberately. Universally irrelevant words — “jobs”, “salary”, “diy”, “tutorial” for most advertisers — belong at campaign level (or in a shared negative list applied across campaigns). Words that are wrong for one ad group but right for another belong at ad-group level. “Cheap” might be poison for your premium line and fine for your budget line.

Re-run it on a cadence. Query mix drifts — new broad match keywords, Google’s matching getting looser, seasonality. A 30–90 day window, revisited monthly, keeps the pattern table honest. And if a large share of your spend is in Performance Max, remember that most n-gram workflows can’t see those queries at all — here’s how to get at PMax search terms.

N-gram analysis is one detector in a bigger discipline. Zero-conversion keywords, underperforming ads, and duplicate keywords all leak budget in their own ways — the full picture is in our guide to finding and eliminating wasted ad spend.

FAQ

What is an n-gram in Google Ads?

An n-gram is a sequence of n consecutive words extracted from a search term. “Free crm software” contains the 1-grams free, crm, software, the 2-grams free crm and crm software, and one 3-gram. N-gram analysis aggregates cost, clicks, and conversions from every search term into every gram it contains, so recurring word patterns — and the money they burn — become visible even when each individual query looks insignificant.

Should I use 1-grams or 2-grams?

Both, for different jobs. 1-grams are for discovery — they aggregate the most data per row, so patterns surface fastest. 2-grams are for action — they make tighter, safer negatives. A typical workflow: spot “free” in the 1-gram view, drill into its terms, discover the waste is concentrated in “free crm”, and block that 2-gram instead of the risky single word. 3-grams occasionally isolate a specific junk phrase, but they fragment the data quickly.

Is there a free n-gram analysis tool for Google Ads?

Yes. Our n-gram analyzer is free, requires no signup, and runs entirely in your browser — you paste your search terms export and nothing is uploaded anywhere. Google Ads scripts are also free if you’re comfortable installing and maintaining code, and a plain spreadsheet works for 1-grams if you follow the word-boundary recipe above.

Do Google Ads n-gram scripts still work in 2026?

Yes — well-maintained ones run fine. The trade-offs haven’t changed: you’re authorizing third-party code against your ad account, you own the maintenance when Google changes something, they can’t see most Performance Max queries, and the output is a spreadsheet you still have to act on manually. If you like scripts, use a maintained one from a reputable author. If you don’t, nothing about n-gram analysis requires them anymore.

Run it on your account today

The fastest way to find out what n-gram analysis knows about your account:

  1. Two minutes, zero commitment: export your search terms report and paste it into the free n-gram analyzer. Worst patterns on top, nothing leaves your browser.
  2. Five minutes, still free: connect your account for a free Google Ads audit and get the wasted-spend scan — zero-conversion keywords, junk query patterns, and what they’re costing you — before you decide whether a paid plan earns its keep.

Either way: before you block anything, open the terms behind the gram and look at the conversions column. That habit is worth more than any tool.

Find your wasted spend in minutes

Connect Google Ads and Keyword Ninja shows you exactly what to cut.

Start free