Lee Foot

Search Results Clustering

Cluster keywords by the ranking URLs they share, with a 0 to 100 consolidation score for each cluster.

Launch the app → View the source

#about

Groups keywords that rank with the same URLs and scores each cluster from 0 to 100 on shared URLs, connectedness and size, from "Keep separate" to "Strong consolidation candidate".

SERPs come from your export CSVs or from the DataForSEO Standard queue (about $0.0006 per keyword per 10 results), collected with a job file, which can take 25 minutes or more.

The hosted app uses connected components; the CLI script adds clique and core-based methods and an overlap penalty.

Streamlit app

Platform
Browser-based (no installation required)
Input
SERP export CSVs (query and URL columns), or a keyword list plus DataForSEO login and password
Output
CSV with clusters and consolidation scores

Use cases

  • Detecting keyword cannibalisation via SERP overlap
  • Prioritising content consolidation by score
  • Finding keywords that can share a page
  • Understanding how Google groups related queries

#features

  • Hosted app: connected components clustering with shared URLs slider (1-10, default 4)
  • CSV upload or SERPs from the DataForSEO Standard queue (10 to 100 results per keyword, send now, collect later)
  • CLI script: three strategies (connected, cliques, core) or all at once
  • Consolidation scoring 0-100 with recommendation bands
  • Core strategy connectivity threshold (default 0.7, CLI only)
  • Overlap detection and scoring penalty across clusters (CLI only)
  • Clusters named after the shortest query; unclustered keywords kept as NO_CLUSTER

#how-to-use

  1. Export SERP data as query and URL pairs, or prepare a keyword list plus DataForSEO credentials
  2. Hosted app: upload CSVs (first column is read as the query, second as the URL), or send searches and collect them with the job file about 30 minutes later
  3. CLI script: place Batch_Results_*.csv files (with search.q and result.organic_results.link columns) in the serp_exports folder, or run send --keywords-file with credentials, then collect --job
  4. Set the minimum shared URLs threshold (default 4)
  5. Run clustering and review clusters sorted by consolidation score
  6. Download the results CSV

#faq

Why does it take two steps?
Google now routes result links through google.com/goto, and DataForSEO's instant (Live) requests leave many of them unresolved, so the real URL and domain are missing. Its Standard queue resolves them, but a search can take 25 minutes or more. So the tool sends the searches and gives you a job file, and you collect the results from that file later. DataForSEO keeps finished searches for 30 days.
What exact input format is required?
In CSV mode the Python script reads CSVs named Batch_Results_*.csv from a serp_exports folder and requires two columns with the exact headers 'search.q' and 'result.organic_results.link' (the format SERP batch exports use). The hosted Streamlit app is more forgiving: it takes whatever files you upload and uses the first column as the query and the second as the URL, ignoring header names. Both the script and the app can instead send a keyword list to DataForSEO and collect the SERPs later from a job file.
Are all three clustering strategies available in the hosted app?
No. The Streamlit app implements connected components only, with a shared URLs slider (1 to 10, default 4). The cliques and core strategies, the CLUSTERING_STRATEGY setting and the overlap penalty exist only in the downloadable Python script.
What does fetching SERPs from DataForSEO cost?
Each keyword is one search in the DataForSEO Standard queue, at an estimated $0.0006 per 10 results (10 by default, up to 100). A search can take 25 minutes or more, so you send the searches, keep the job file and collect later; collecting costs nothing. Credentials go in via the sidebar (app) or the --login and --password flags or DATAFORSEO_LOGIN and DATAFORSEO_PASSWORD environment variables (script). CSV mode uses no API at all.
Why does the same keyword appear in several rows of the script output?
With CLUSTERING_STRATEGY = 'all' (the default) the script runs all three strategies and outputs every cluster from each, so one keyword can appear up to three times under different cluster_type values. Set the strategy to 'connected', 'cliques' or 'core' if you want one row per keyword.
How is the 0-100 consolidation score calculated?
Base score of up to 40 from average shared URLs (average x 4, capped), plus connectivity x 30 (the share of keyword pairs in the cluster that actually meet the URL threshold), plus a size bonus of 5 points per keyword beyond two (capped at 20), minus an overlap penalty of 5 per query that sits in multiple clusters (capped at 10, script only). 80+ is a strong consolidation candidate, under 20 means keep separate.
How are clusters named and what does NO_CLUSTER mean?
Each cluster takes the shortest query in it as its name. Queries that share fewer than the threshold number of URLs with every other query are still included in the output, assigned to NO_CLUSTER with a score of 0 and the recommendation 'Keep separate', so the output always contains your full keyword list.

/contact

Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.