A Google Ads Script that analyzes search term reports to identify costly word patterns using n-gram analysis. Surfaces money-wasting unigrams, bigrams, and trigrams sorted by cost.
- Pulls all search terms with cost via GAQL
- Breaks each search term into configurable n-grams (1-word, 2-word, 3-word patterns)
- Aggregates cost, clicks, impressions, and conversions per n-gram
- Sorts by cost descending to surface the biggest money wasters
- Sends an email report and optionally exports to a Google Sheet
- In Google Ads, go to Tools & Settings > Bulk Actions > Scripts
- Paste the contents of
main_en.gs(ormain_fr.gsfor French) - Update the
CONFIGvalues - Set
TEST_MODEtofalsewhen ready - Schedule the script weekly
| Parameter | Type | Default | Description |
|---|---|---|---|
TEST_MODE |
Boolean | true |
No functional difference — report is always sent |
NOTIFICATION_EMAIL |
String | — | Email address for the n-gram analysis report |
SHEET_URL |
String | '' |
Optional Google Sheet URL for export (empty = skip) |
NGRAM_SIZES |
Array | [1, 2, 3] |
Which n-gram sizes to analyze |
MIN_COST |
Number | 5 |
Minimum aggregated cost to include an n-gram |
MIN_IMPRESSIONS |
Number | 10 |
Minimum impressions to include |
TOP_N |
Number | 50 |
Number of top n-grams in the report |
DATE_RANGE |
String | LAST_30_DAYS |
GAQL date range |
- Runs a GAQL query on
search_term_view - Generates all n-grams of configured sizes from each term
- Aggregates metrics per unique n-gram
- Filters, sorts by cost, and takes top N
- Sends email report and optionally writes to Sheet
- Google Ads account with Search campaigns
- Google Ads Scripts access
MIT — Thibault Fayol Consulting