Skip to content

feat(prompts): suggest prompts from the pages analytics says are worth it - #720

Merged
gkhngyk merged 2 commits into
mainfrom
feature/705-ga-prompt-suggestions
Aug 13, 2026
Merged

gkhngyk merged 2 commits into
mainfrom
feature/705-ga-prompt-suggestions

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Prompt suggestions came from LLM generation, heuristics and Search Console demand. Search Console answers what are people typing into a search box; the traffic pipeline (#704) answers two questions it structurally cannot, because they describe behaviour rather than search volume.

signal what it finds
revenue_blind_spot pages that earn and that nothing tracked would surface in an AI answer
ai_momentum pages an AI engine already refers visitors to

The first finds what is missing, the second what is already working. The candidate list interleaves them rather than concatenating: a combined sort would let a shop with real revenue fill every slot and leave no room for momentum, and a brand without ecommerce would produce nothing from the revenue side at all. Revenue ranks on money where the property reports it and on key events where it does not — which is what makes this work without ecommerce tracking, one of the acceptance criteria.

The prompt is derived from the page, not from its URL or product name. A model number is not something anyone asks an assistant about; the answerable question sits at the category and need level, and reading the page is how we get there — which is also why this needs no product catalogue. The model receives the page's own title, h1, description and headings. A page that cannot be read is dropped rather than passed on as a slug for the model to guess from.

Transactional pages are excluded by path segment, not substring. A GA4 purchase fires on the confirmation page, so without the filter the highest-revenue "page" in most shops is /checkout; a substring match would quietly delete /cartography-guides along with /cart.

Provenance follows the Search Console pattern. A suggestion is 'ga' only when its sourcePage matches a candidate actually offered, so a fabricated one degrades to a plain 'llm' row instead of carrying invented figures. Search Console wins a tie — it is proven demand for a phrasing, while the page is an inference about what would lead there.

The card shows the evidence alongside the suggestion (Analytics · /pricing, #2 by revenue or AI traffic · 25 sessions), with the reasoning in the tooltip. As with Search Console rows, the modelled ~X/mo estimate is hidden on measured rows — showing an estimate next to measured data reads as a contradiction.

Related issue

Closes #705

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

Automated — cd server && yarn test (249 pass; 22 new in src/lib/ga-suggestions.test.js covering transactional exclusion, per-page aggregation, platform attribution, interleaving, the no-ecommerce fallback, dismissal, de-duplication and page-summary extraction).

Against a connected property:

  1. Map a brand to a GA4 property and let the traffic sync run (or trigger it via POST /api/integrations/google-analytics/sync).
  2. Refresh the prompt suggestions card. Suggestions derived from analytics carry an Analytics · <page> badge and an evidence badge, with the reasoning in the tooltip.
  3. Dismiss one — the same page stays out of the candidate pool for 30 days.
  4. A brand without the connection, without synced traffic, or a self-host without Composio credentials sees exactly what it sees today.

Verified against a live connected property before opening this: three candidates in six seconds, each carrying the engines that referred it and the page's own words rather than its slug.

Two honest gaps in that live run, both covered by unit tests instead: the property reports no conversions, so it exercised the momentum path and the no-ecommerce fallback but not revenue_blind_spot; and the coverage filter changed nothing there, because none of the 80 tracked prompts overlapped those pages.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/ and server/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • supabase/schema.sql regenerated via bash supabase/build-schema.sh
  • Changes are focused — one concern per PR

…h it

Suggestions came from LLM generation, heuristics and Search Console demand.
Search Console answers what people type into a search box; the traffic
pipeline answers two questions it structurally cannot, because they describe
behaviour rather than search volume.

Revenue blind spots are pages that earn and that nothing tracked would
surface in an AI answer — a commercial gap stated in the customer's own
numbers. AI momentum is the inverse: pages an engine already refers visitors
to, which proves the topic is answerable and the brand is already a candidate
source for it. The two are complements, so the candidate list interleaves
them; concatenating would let a shop with real revenue fill every slot and
leave no room for what is already working, and a brand without ecommerce
would produce nothing from the revenue side at all. Revenue ranks on money
where the property reports it and on key events where it does not, which is
what makes this work without ecommerce tracking.

The prompt is derived from the page, not from its URL or product name. A
model number is not something anyone asks an assistant about; the answerable
question sits at the category and need level, and reading the page is how we
get there — which is also why this needs no product catalogue. A page that
cannot be read is dropped rather than passed on as a slug for the model to
guess from.

Transactional pages are excluded by path segment, not by substring: a GA4
purchase fires on the confirmation page, so without the filter the
highest-revenue "page" in most shops is the checkout, while a substring match
would quietly delete /cartography-guides along with /cart.

Provenance follows the Search Console pattern — a suggestion is 'ga' only
when its sourcePage matches a candidate we actually offered, so a fabricated
one degrades to a plain 'llm' row instead of carrying invented figures. Search
Console wins a tie: it is proven demand for a phrasing, while the page is an
inference about what would lead there.

Verified against a live connected property: three candidates in six seconds,
each carrying the engines that referred it and the page's own words. That
property reports no conversions, so it exercised the momentum path and the
no-ecommerce fallback; the coverage filter changed nothing there because no
tracked prompt overlapped those pages.

Closes #705
…module

`lib/actions/prompt-suggestions.ts` is `'use server'`, where every runtime
export has to be an async server action. The two synchronous narrowing
helpers added with the Analytics source therefore failed the production
build with "export gscSourceData was not found" — while tsc, eslint and
prettier all passed, because none of them run the Next build.

The types and their guards now live in a plain module and the server-action
file imports the types alone.
@gkhngyk
gkhngyk merged commit 7c528f4 into main Aug 13, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the feature/705-ga-prompt-suggestions branch August 13, 2026 19:43
@gkhngyk gkhngyk mentioned this pull request Aug 24, 2026
7 of 12 tasks
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.

Prompts: suggest prompts from the pages AI traffic converts on — Google Analytics Phase 4

1 participant