I built this actor; it's a paid tool on Apify with a free trial credit.
Most Google Trends tutorials stop at the interest-over-time line. The part I find more useful for actual decisions is interest by region: where in the country people search for one thing more than another. If you're splitting an ad budget across states, or picking which city gets a launch first, that's the table you want.
This post pulls that data with my Google Trends Scraper from Python and turns it into a ranked list of states. My earlier post covered the basics and a weekly keyword tracker; this one is only about regions.
Two ways to read regional data
-
One keyword: each region gets a 0-100 score, where 100 is the region with the highest share of searches for that term. For
mortgage ratesover the past 12 months (US), Wyoming scored 100, Kansas 49 and Colorado 48. - A comparison (up to 5 comma-separated keywords on one line): each region's values split that region's searches between your keywords and add up to 100. This is the one for "where do people want A rather than B".
A real comparison: iPhone vs Samsung Galaxy
I ran iphone, samsung galaxy for the US, past 12 months, with region resolution set to states. Nationally the gap is huge (average 61.4 vs 4.3 on the timeline), but the state split shows where Samsung does relatively best:
| State | iphone | samsung galaxy |
|---|---|---|
| Wyoming | 82 | 18 |
| Kansas | 92 | 8 |
| New York | 92 | 8 |
| District of Columbia | 92 | 8 |
| Florida | 93 | 7 |
| ... | ||
| Vermont | 96 | 4 |
| Louisiana | 97 | 3 |
So a Samsung accessory seller would get roughly 6x the relative interest in Wyoming compared to Louisiana. Those are real values from the run, all 51 regions came back in one result.
The code
pip install apify-client
import csv
from apify_client import ApifyClient
client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("rel8ble/google-trends-scraper").call(run_input={
"searchTerms": ["iphone, samsung galaxy"],
"geo": "US",
"timeRange": "today 12-m",
"regionResolution": "REGION", # states; "DMA" = US metro areas, "CITY" = cities
"includeRelatedQueries": False, # only regions needed: faster run
"includeRelatedTopics": False,
})
TARGET = "samsung galaxy"
for r in client.dataset(run["defaultDatasetId"]).iterate_items():
rows = []
for reg in r.get("interestByRegion", []):
values = reg["values"]
total = sum(values.values()) or 1
rows.append((reg["geoName"], reg["geoCode"], values[TARGET], round(values[TARGET] / total, 3)))
rows.sort(key=lambda x: x[3], reverse=True)
for name, code, value, share in rows[:10]:
print(f"{name:<22} {code:<6} {value:>3} share {share:.0%}")
with open("target-states.csv", "w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow(["state", "code", TARGET, "share"])
w.writerows(rows)
Each item in interestByRegion looks like this:
{ "geoCode": "US-WY", "geoName": "Wyoming", "values": { "iphone": 82, "samsung galaxy": 18 } }
The geoCode values (US-WY, US-KS, ...) match the region codes most ad platforms accept in bulk location uploads, so the CSV is close to ready for a location bid adjustment sheet.
Going finer: metro areas
Set regionResolution to "DMA" to get US designated market areas instead of states. That's the same geography TV and many local ad buys use. "CITY" works too, but Google only returns cities with enough volume, so small keywords come back sparse.
Things to keep in mind
- Shares, not volumes. Wyoming at 18 doesn't mean Wyoming has many Samsung searches; it means that of the searches for these two terms in Wyoming, a bigger slice went to Samsung. Combine it with population or your own conversion data before moving real budget.
- Keep the comparison on one line. Values from separate searches are on different scales and can't be compared to each other.
- Small regions are noisy. Google Trends samples its data, and low-population states can swing a few points between runs. Run it twice, or use 12 months instead of 30 days, before you act on a small difference.
-
hasData: falsemeans the term doesn't have enough volume for Google to show anything.
Cost
$2.50 per 1,000 results, and one comparison (up to 5 keywords, all 51 states included) is one result. Checking 20 product pairs every month comes to about $0.05. Apify's free plan includes $5 of monthly credit.
Google Trends Scraper on Apify ยท Python examples: google-trends-api-python on GitHub
This article was drafted with AI and published by me.
Top comments (0)