Skip to content

feat(insights): visibility rate as the headline metric across Insights - #490

Merged
gkhngyk merged 6 commits into
mainfrom
feature/insights-headline-metrics
Jul 20, 2026
Merged

gkhngyk merged 6 commits into
mainfrom
feature/insights-headline-metrics

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

The Insights headline was the average visibility score over ALL results. Every answer the brand is absent from contributes a 0, and tracking many platforms dilutes each appearance further — so the number reads near zero for most brands and buries the fact users act on: how often the brand actually shows up. This PR switches the whole visibility narrative to one prompt-level metric, end to end:

  • KPI row: a new Visibility Rate card leads the row — distinct prompts the brand appeared in ÷ distinct prompts that produced results, under the same filters as the rest of the row (the Tracked Prompts KPI is the denominator on purpose, so the two cards always agree). Clicking it opens the existing per-model breakdown sheet, where the score average lives on. The old Visibility Score card is gone; Tracked Prompts / Mentions / Citations / Positive Sentiment are unchanged.
  • Leaderboard: ranks and displays the same rate for the brand and every competitor, with an identical denominator for everyone (the fix(insights): use the same denominator for brand and competitor averages #478 same-denominator rule kept — absence still costs; but a prompt counts once no matter how many platforms answered it). Each row shows mentions · citations plus the fraction behind its percentage (appeared in X/Y prompts), and the delta badge is the rate's point change vs the previous window.
  • Provider chart: the Brand vs Competitors bars plot the same rate per provider instead of the score average, dividing everyone by the brand bucket's prompt count.

Backend

Two additive RPC changes, both applied to the hosted DB:

  • visible_prompt_stats (00027) — distinct prompts appeared / visible result rows / their score sum, mirroring tracked_prompt_count's filters and the feat(shopping): org-level "Shopping mode" toggle + ChatGPT Shopping platform + Insights isolation #155 shopping exclusion.
  • competitor_aggregates (00028 + 00029) — distinct-prompt counts overall and per (model_used, platform) group, for the brand and each competitor. Payload shape is additive; existing readers are unaffected. Summing DISTINCT counts across two engines of one provider counts a shared prompt once per engine in numerator and denominator alike, so folded rates stay unbiased.

Related issue

Follow-up to #457 (Tracked Prompts KPI) and #478 (same-denominator leaderboard rule); metric direction discussed with the team.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open /dashboard/insights — the first KPI card is Visibility Rate (a percentage), and the row has 5 cards; clicking the card opens the visibility breakdown sheet.
  2. Change the date preset / model / region / topic filters — the rate, the leaderboard and the provider chart all move together and never disagree with the Tracked Prompts count.
  3. Leaderboard: every row shows N%, a mentions · citations line and appeared in X/Y prompts where X/Y matches the displayed percentage; the brand's Y equals the Tracked Prompts KPI.
  4. Provider chart: bars are percentages on the same scale as the leaderboard (e.g. a brand visible in 18 of 107 ChatGPT prompts shows ~17%).
  5. Share of Voice keeps its own chart section below (no KPI card).
  6. A brand with zero appearances in the window shows 0% without errors.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

gkhngyk added 6 commits July 20, 2026 14:59
Averaging visibility over ALL results reads near zero for most brands —
every answer the brand is absent from contributes a 0, and tracking many
platforms dilutes each appearance further. That number buried the two
facts users act on: how often the brand shows up, and how good it looks
when it does. Competing tools headline exactly those two.

The KPI row now leads with Visibility Rate (distinct prompts the brand
appeared in / prompts that produced results, same filters as the row —
the Tracked Prompts KPI is the denominator on purpose) with the quality
split in its sub-line (avg score over only the answers the brand is in),
and Share of Voice (already computed for the charts, now surfaced with
its period delta). The raw average leaves the headline; it lives on in
the rate's sub-line and the per-model breakdown sheet.

New visible_prompt_stats RPC (00027) mirrors tracked_prompt_count's
filters and shopping exclusion; applied to the hosted DB. sovData is no
longer nulled when per-platform rows are empty — the chart section gates
on byPlatform itself so the KPI card keeps overallSov.
Follow-up to the Visibility Rate headline: the Brand vs Competitors
leaderboard still displayed the all-rows score average, which reads ~1%
for a brand that appears in a third of its prompts and contradicted the
new headline number sitting right above it.

competitor_aggregates (00028, applied to the hosted DB) now also returns
distinct-prompt counts: total prompts in the window plus per-entity
prompts-appeared, for the brand and each competitor. The leaderboard
ranks and displays visible_prompts / prompt_count with the same
denominator for everyone (#478 rule kept — absence still costs), and its
delta badge is the rate's point change vs the previous window. The score
average stays in the payload for the per-provider chart.

Also drops the Visibility Rate KPI card's sub-line per feedback — the
percentage stands alone.
Replace each row's mentions · citations sub-line with the fraction
behind the displayed rate (appeared in X/Y prompts) so the number and
its explanation sit together. Entries carry the raw numerator and the
shared denominator alongside the percentage.
Six cards made the KPI row cramped; SoV keeps its own chart section
below with the same number and delta, so the headline card was
redundant. sovData handling reverts to chart-gated.
Completes the rate switch: the Brand vs Competitors provider bars still
plotted the all-rows score average, contradicting the leaderboard next
to them. competitor_aggregates (00029, applied to the hosted DB) now
carries distinct-prompt counts per (model_used, platform) group, and the
provider fold divides everyone by the brand bucket's prompt count — the
same-denominator rule at provider granularity. Summing DISTINCT counts
across two engines of one provider counts a shared prompt once per
engine in numerator and denominator alike, so the folded rate stays
unbiased.
Bring the mentions · citations line back above the appeared-in fraction
— dropping it lost the intensity signal that explains rate ties (many
citations vs broad-but-shallow presence).
@gkhngyk

gkhngyk commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Added a refetch overlay on top of the rate work: on a date/filter change the content dims under a small floating spinner instead of silently showing the previous window's numbers until the new payload lands. First load keeps the skeleton; the filter bar stays interactive during the reload.

gkhngyk added a commit that referenced this pull request Jul 21, 2026
…ate (#499)

Part of #493. The leaderboard's Visibility (30d) column, the Best
performer / Biggest gap / Top mover KPI cards, sorting and the CSV
export now use the #490 rate (distinct prompts the brand appeared in ÷
distinct prompts with results, same appeared rule as Insights) instead
of the raw score average that read near zero for most brands. The 7d
change is the rate difference in points, the sparkline tracks the daily
visible-answer share, the cell tooltip shows appeared-in X of Y prompts,
and the export gains visible_prompts / active_prompts columns.

The topic detail page still reads from the Insights primitives and
remains #493 scope.
gkhngyk pushed a commit that referenced this pull request Jul 22, 2026
…denominator (#491) (#502)

Three changes, all additive:

1. getVisibilitySummaryFor — adds visiblePrompts, promptCount and
   visibilityRatePct to totals. Counts distinct prompt_ids from the
   same filtered prompt_results rows (chatgpt-shopping excluded).
   A prompt is 'visible' when mention_count > 0 OR citation_count > 0,
   matching the visible_prompt_stats RPC and the Insights KPI card.

2. getVisibilitySummaryFor — fixes topCompetitors[].avgVisibility to
   divide by the total result-row count (same denominator as the brand)
   instead of the competitor's own mention count. Prevents inflated
   scores for competitors that only appear in their best runs (#478).

3. getCompetitorComparisonFor — maps brand_prompt_count,
   brand_visible_prompts and by_competitor[].visible_prompts from the
   competitor_aggregates RPC (already present since #490) to new output
   fields: visibility_rate_pct, visible_prompts, prompt_count on both
   brand and every competitor. All rates share brand_prompt_count as
   the denominator so entries are directly comparable, matching the
   dashboard leaderboard. avg_visibility_score kept for backward compat.

Updates MCP tool descriptions so an assistant knows visibilityRatePct /
visibility_rate_pct is the headline and avgVisibility is the intensity
score.

yarn lint, yarn typecheck, yarn format:check all pass from web/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant