Why Google Trends?
Search interest often moves 4–6 weeks before earnings surprises. When people search for a brand more, they're engaging with it more — buying, researching, or reacting to a product launch. pytrends is a free, unofficial Python wrapper around the Google Trends API. No key required.
What to Track
- Brand name search interest — weekly, relative to 12-month baseline
- Product category queries vs competitor brand queries — competitive positioning
- Geographic interest breakdown — is a brand growing in new markets?
- Related queries rising — new associations forming
HEARTBEAT Configuration
name: trends_monitor
schedule: "0 8 * * 1"
steps:
- fetch_trends:
keywords:
- "Apple"
- "Samsung"
- "Google Pixel"
timeframe: "today 3-m"
geo: "US"
- compare:
baseline: 12_week_average
flag_if_change_pct_exceeds: 25
- llm:
prompt: |
Analyze these Google Trends results for my watchlist.
Flag any keyword showing unusual acceleration or deceleration vs baseline.
Data: {{ trends_data }}
- notify:
channel: email
subject: "📈 Weekly Trends Brief — {{ date }}"
pytrends Python Implementation
Core Function: Fetch Brand Trends
from pytrends.request import TrendReq
import pandas as pd
def get_brand_trends(keywords: list, timeframe: str = "today 3-m", geo: str = "US"):
pytrends = TrendReq(hl="en-US", tz=360)
pytrends.build_payload(keywords, timeframe=timeframe, geo=geo)
df = pytrends.interest_over_time()
if "isPartial" in df.columns:
df = df.drop(columns=["isPartial"])
return df
# Compare current week vs 12-week average
def trend_velocity(df: pd.DataFrame) -> dict:
results = {}
for col in df.columns:
recent = df[col].iloc[-1]
baseline = df[col].iloc[-13:-1].mean()
pct_change = ((recent - baseline) / baseline) * 100 if baseline > 0 else 0
results[col] = {"recent": recent, "baseline": round(baseline, 1), "change_pct": round(pct_change, 1)}
return results
Competitor Comparison
def compare_competitors(brand: str, competitors: list, timeframe: str = "today 12-m"):
all_keywords = [brand] + competitors
# Google Trends allows max 5 keywords at once
chunks = [all_keywords[i:i+5] for i in range(0, len(all_keywords), 5)]
frames = []
pytrends = TrendReq(hl="en-US", tz=360)
for chunk in chunks:
pytrends.build_payload(chunk, timeframe=timeframe, geo="US")
df = pytrends.interest_over_time()
frames.append(df)
return pd.concat(frames, axis=1).loc[:, ~pd.concat(frames, axis=1).columns.duplicated()]
Limitations
Frequently Asked Questions
No — it's an unofficial wrapper. Google doesn't provide an official Trends API. It's widely used but could break if Google changes their backend.
Rate limit gently — no more than a few requests per minute. Build in sleep() between calls.
Yes, pytrends has a related_queries() method that surfaces breakout and rising associated terms.
Next Steps
Now that you understand how to automate Google Trends monitoring, move to Part 2: Job Posting Intelligence to layer hiring signals on top of search trends. The combination of rising brand search interest plus aggressive hiring is a powerful convergent signal.