A Jupyter notebook that uses the Google Trends API to calculate and visualize Share of Search across competing brands — a leading indicator of market share and brand health.
Most PMs making competitive decisions rely on analyst reports (expensive and lagging) or gut feel. Share of Search — the percentage of branded search interest your brand captures versus competitors — is a free, publicly available signal that correlates with market share shifts 6–12 months before they show up in revenue data.
The problem: extracting this from Google Trends manually does not scale. You would need to export CSVs per competitor set, align time windows, and calculate percentages by hand every time a stakeholder asks. This notebook automates that entire workflow in one configurable run.
Share of Search measures the proportion of branded search interest a company captures relative to its competitors. Research by Les Binet and others has shown it to be a strong leading indicator of market share, often predicting shifts 6–12 months before they appear in sales data.
Search interest data from Google Trends is an index (0–100), not absolute search volume. SoS reflects relative interest across competitors, not raw numbers.
- Fetches weekly branded search interest via the Google Trends API (
pytrends) - Configurable competitor list, date range, and country/region
- Calculates Share of Search (%) per brand
- Exports clean data to CSV
- Three visualizations:
- Combined time-series (monthly averages)
- Individual trend lines per competitor
- Pie chart with SoS breakdown
git clone https://github.com/elmarto87/share-of-search.git
cd share-of-searchpip install -r requirements.txtjupyter notebook Share_of_Search_SoS.ipynbAll settings are in Cell 2 of the notebook:
# List of competitors to compare (max 5, Google Trends limit)
competitors_list = ["salesforce", "hubspot", "zoho", "oracle", "dynamics"]
# Date range — format: "YYYY-MM-DD YYYY-MM-DD"
timeframe = "2022-01-01 2025-01-01"
# Country: two-letter ISO code (e.g. "US", "GB", "MX") or "" for Worldwide
geo = "US"| Parameter | Description | Example |
|---|---|---|
competitors_list |
Brand keywords to compare (max 5) | ["nike", "adidas", "puma"] |
timeframe |
Date range for the analysis | "2020-01-01 2025-01-01" |
geo |
Country ISO code or blank for worldwide | "US", "GB", "" |
The notebook produces:
| Output | Description |
|---|---|
sos_<geo>_<timeframe>.csv |
Weekly interest data, ready for further analysis |
| Time-series chart | Monthly average interest per brand over time |
| Subplots chart | Individual trend lines per competitor |
| Pie chart | Share of Search breakdown as percentages |
Example summary table (US, 2022–2025):
| Brand | Total Interest | Share of Search |
|---|---|---|
| Oracle | 10,050 | 36.3% |
| Salesforce | 9,898 | 35.7% |
| Dynamics | 3,950 | 14.3% |
| HubSpot | 2,389 | 8.6% |
| Zoho | 1,617 | 5.8% |
1. Google Trends (free) vs. paid competitive intelligence tools Considered SimilarWeb and SparkToro for branded traffic data, but their paid tiers are inaccessible for most individual PMs. Google Trends is free, covers 200+ countries, and returns a signal strong enough for directional strategic decisions. The tradeoff: it is a relative index (0–100), not absolute volume — it shows who captured more interest, not how many searches occurred.
2. Enforcing the 5-competitor limit as a design constraint Google Trends caps queries at 5 keywords. Rather than building workarounds with multiple API calls and normalization math, I kept the limit as-is. It forces clearer thinking about who your primary competitors actually are — a useful strategic exercise before running the analysis.
3. Weekly granularity over daily Daily data caps out at roughly 9 months of history and is noisier. Weekly data gives 5+ years of history with a smoother signal — the right choice for strategic trend analysis. Daily granularity would make sense for a different use case: monitoring a specific campaign window.
- The relative index means you cannot compare SoS values across different time windows. Picking one consistent timeframe for the full competitive set is not optional — mixing windows breaks the math silently.
- Monthly resampling of weekly data cuts noise dramatically without losing the trend signal. Raw weekly charts are too choppy for executive presentations.
- Google Trends rate-limits aggressively. For more than 3–4 API calls in a session, add
time.sleep(10)between calls or expect 429 errors with no warning.
- Google Trends returns a relative index (0–100), not absolute search volume
- Results can vary slightly between API calls due to Google's sampling
- The API may rate-limit heavy usage — add
sleepdelays if needed - Google Trends caps comparisons at 5 keywords per request
- Very niche brands with low search volume may return mostly zeros
- Python 3.9+
- See
requirements.txtfor package versions
MIT — see LICENSE
Contributions are welcome! See CONTRIBUTING.md for guidelines.