DEV Community

tienlq2011
tienlq2011

Posted on

How to compare more than 5 keywords in Google Trends (on one scale)

Google Trends has a hard limit: you can compare at most 5 search terms at once. And every comparison gets its own 0–100 scale, where 100 is the peak of that comparison.

So if you want to rank 30 product names, 50 keywords for a content plan, or every coin in your watchlist, you can't just run six comparisons and paste the numbers together. "Ramen = 40" in one batch and "Pho = 40" in another batch mean completely different things.

Here's the trick I use to put any number of terms on one scale, plus a small Python version you can copy.

The anchor trick

Pick one term to be the anchor. Put it in every batch, together with 4 other terms:

batch 1: [anchor, A, B, C, D]
batch 2: [anchor, E, F, G, H]
batch 3: [anchor, I, J, K, L]
...
Enter fullscreen mode Exit fullscreen mode

The anchor is the same search term, over the same time range and location, in every batch. Its real search interest doesn't change, so any difference in its value between batches is just Google's rescaling. That tells you exactly how much to multiply each batch by to bring it back to the scale of batch 1:

factor = mean(anchor in batch 1) / mean(anchor in batch N)
value_on_shared_scale = value_in_batch_N * factor
Enter fullscreen mode Exit fullscreen mode

In Python, given each batch as a list of dicts with an interestOverTime series:

def mean(item):
    vals = [p["value"] for p in item["interestOverTime"] if p["value"] is not None]
    return sum(vals) / len(vals) if vals else 0


def normalize(batches):
    """batches[i][0] is always the anchor term."""
    base = mean(batches[0][0])
    out = list(batches[0])
    for batch in batches[1:]:
        m = mean(batch[0])
        for item in batch[1:]:
            if not m:
                item["error"] = "anchor has no data in this batch"
                continue
            for p in item["interestOverTime"]:
                if p["value"] is not None:
                    p["value"] = round(p["value"] * base / m, 2)
            out.append(item)
    return out
Enter fullscreen mode Exit fullscreen mode

After this, every term lives on the scale of the first batch. Values can go above 100 and have decimals, and that's fine: they're relative, the same as the original Trends index.

Things that will bite you

  • Pick a medium-popularity anchor. Google returns whole numbers from 0 to 100. If your anchor is tiny next to the other terms, it gets rounded to 0 or 1, and the factor becomes garbage. If it's huge, the other terms get squashed to 0. Something in the middle of your list works best.
  • If the anchor has no data in a batch, don't guess. Return an error for that batch instead of dividing by zero or making up numbers.
  • Only the timeline can be rescaled. Interest by region and related queries use their own scale per term on the Google Trends site too, so you can't join them the same way.
  • Trends is sampled. Numbers shift a little between runs, especially for niche terms. Don't read too much into a 2-point difference.

Getting the data without a headless browser

Most Google Trends scrapers drive a headless browser, which is slow and tends to hang on page loads. The Trends website itself loads its charts from JSON endpoints (/trends/api/explore, then one request per widget), so you can call those directly with any HTTP client. Two things matter:

  1. Google blocks datacenter IPs quickly, so use residential proxies and a fresh IP per retry.
  2. Handle every term on its own, so one blocked term doesn't kill the whole run.

If you'd rather not maintain that yourself, I packaged all of the above (anchor comparison included, plus regions, related queries and "Trending now") as an Apify Actor: Google Trends Scraper & API. Turn on compareAll and pass as many terms as you want:

{
  "searchTerms": ["pizza", "sushi", "tacos", "pho", "ramen", "burger", "kebab"],
  "compareAll": true
}
Enter fullscreen mode Exit fullscreen mode

It costs $2 per 1,000 terms, and failed terms are free.

Questions about the rescaling or the edge cases? Ask in the comments, I'm happy to dig in.

Top comments (0)