Repository navigation
Description
Context
Cloro now supports state-level geo-targeting for the AI endpoints: passing a USPS two-letter state code alongside country: "US" routes the request through a proxy in that state and returns localized results. This applies to ChatGPT, Copilot, Perplexity, Gemini, and Grok. Google Search / AI Overview / AI Mode are not affected — those continue to use location / uule for sub-country targeting.
Today a brand only has a country-level region (default US), selected during onboarding and on the Add Brand page, and server/src/lib/cloro-scraper.js sends it as country in every request body. There is no state concept anywhere in the stack, so US customers with local intent ("best electricians near me") can't get state-localized tracking.
Scope
1. Schema
- Add a nullable
statecolumn tobrands(two-letter USPS code). Empty = nationwide, which keeps the current behavior for every existing brand. Numbered migration file undersupabase/migrations/.
2. Web UI
- Onboarding brand step and the Add Brand page (web/src/app/[locale]/(dashboard)/dashboard/brands/new/page.tsx): when the selected region is
US, show an optional "State (optional)" select; hide it and clear the value when any other country is selected. - Brand settings:
statemust be editable after creation, whereverregionis editable today (updateBrandin web/src/lib/actions/brand.ts already supports region updates — extend it). - The state list is a static constant (50 states + DC) in
web/src/config/, next toREGIONSin prompt-options.ts. Do not fetch it from the provider's/v1/statesendpoint at runtime — no external dependency in the UI path.
3. Server
- Thread the brand's
statethrough the tracking pipeline tobuildRequestBodyincloro-scraper.js. - Include
statein the request body only whencountry === 'US'and the task is one of the AI endpoints (chatgpt-web,copilot-web,grok-web,perplexity-web,gemini-web, andchatgpt-shopping, which uses the same CHATGPT task). Never add it to thegoogle-aio/google-aimodepayloads — those branches are already separate inbuildRequestBody, so the split is clean.
Availability
Available on all plans — no plan gating.
Out of scope
- Volume/competition analysis (DataForSEO) — unaffected, keeps country-level targeting.
- Historical results — existing data is untouched; state targeting applies from the next run onward.
Acceptance
- A US brand can pick a state at creation and change it later from settings; non-US brands never see the field.
- Runs for a US+state brand send
stateon AI-endpoint requests only; Google AIO / AI Mode payloads are unchanged. - Brands without a state behave exactly as today.
Activity
feat: optional US state-level geo-targeting for AI prompt tracking (#579