Skip to main content

Competitive position across topics

The dashboard’s Industry rankings widget shows your top-mentioned competitors across all of your tracked conversations. Sometimes you want the finer-grained view: for each topic you track, where do you actually rank? This recipe uses tpc analytics explore to answer that in one script — no dashboard clicking required.

Prerequisites

  • The CLI installed and authenticated. See Installation and Authentication.
  • tpc product switch <product-slug> set to the product you want to check.
  • jq installed locally.

The script

Each topic requires its own ranking lookup, so this runs them concurrently instead of one at a time — each result is captured to a temp file so parallel output doesn’t interleave, then printed back in the original topic order.
Run it:
Example output:

How it works

  1. tpc auth whoami prints your active product’s name, which is what you look for in each topic’s ranking.
  2. tpc analytics explore --metric sov --by topic lists every topic you track, with each topic’s ID (key) and name (label).
  3. For each topic, a background check_topic call runs tpc analytics explore --metric sov --by competitor --topic <topicId> — the same ranking view as the dashboard’s Industry rankings widget, but scoped to one topic instead of everything. All topics are looked up concurrently instead of waiting on each one in turn.
  4. jq picks out the row matching your product’s name and writes its rank and share of voice to that topic’s temp file.
  5. wait blocks until every background lookup finishes, then the results are printed back in the original topic order (not finish order).
The speedup scales with how many topics you track. With a handful of topics, most of the wall-clock time is per-invocation overhead (auth and org resolution), so parallelizing saves less than you’d expect. With dozens of topics, running them concurrently instead of sequentially is the difference between minutes and seconds.
--top 100 is the highest page size the API allows in one page. If a topic has more than 100 tracked competitors and you don’t show up, page through with --page 2 (see tpc analytics explore --help) rather than assuming you’re unranked.

Variations

Just want the overall ranking, not broken out by topic?
Want the raw JSON for a dashboard or Slack digest instead of a formatted table? Drop the printf lines and pipe the jq output directly — every command in this recipe supports --json. Only care about a couple of topics? Skip the topic-listing step and hardcode the topic IDs you already know:

Show competitors around your rank

Knowing your rank and share of voice in a topic is useful, but it doesn’t say who you’re actually competing against right at that position. This script takes one topic and shows the competitors ranked immediately above and below you — reusing the exact same tpc analytics explore --by competitor --topic response as the main script above, since every competitor’s rank is already in that one call. No extra API request needed.
Run it with a topic ID (get one from tpc analytics explore --metric sov --by topic --json, or from the topic-listing step of the script above):
Example output:
Pass a second argument to widen or narrow the window (default is 2 rows on each side):
If you’re ranked #1 (or near the bottom of the tracked list) in a topic, the window just clamps to whatever rows exist in that direction — you’ll see fewer neighbors on that side, not an error.

All topics, with competitors around your rank

Combines both scripts above: loop every topic concurrently (like the first script), but show the window of competitors around your rank in each one (like the one above) instead of just your own row. Same parallel-lookup structure — background jobs writing to per-topic temp files, replayed in original order — just with more rows per topic.
Run it:
Pass a window size as the first argument (default 2):
Example output:
Firing one concurrent request per topic can occasionally trip the API’s rate limit (429 Too many requests) if you’re re-running the script repeatedly in quick succession, for example while iterating on it. Wait a few seconds and retry — it’s a rate limit on request volume, not a problem with your data or account.