AI

How a website tracks brand mentions in Claude and ChatGPT

How a small website automated brand mention tracking in Claude and ChatGPT using 29 questions, web search, Cloudflare Worker, and a strict $2 weekly budget.

·3 min read
How a website tracks brand mentions in Claude and ChatGPT

Small websites often face a visibility problem in AI tools like Claude and ChatGPT, where user queries about specific topics yield answers that omit the resource entirely. Since this traffic never hits standard search rankings or web metrics, understanding whether content and markup improvements actually work requires measuring the AI responses directly.

  • The tracking system automates a weekly run of 29 specific questions (19 in Russian and 10 in Kazakh) through the Claude model with web search enabled.
  • The entire logic runs on a free-tier Cloudflare Worker without complex queues or databases, operating under a strict 2-dollar weekly budget cap.
  • For each question, the system logs three core facts: whether the website is mentioned, whether the author or methodology is referenced, and what other domains the model cites.

Architecture and schedule on Cloudflare Worker

To implement this efficiently, the developers chose a single Cloudflare Worker on a free plan, triggered by a scheduled cron job. The cron wakes up the worker every two minutes on Mondays, calculating the specific question number directly from the current minute of the hour, running all 29 queries between 06:00 and 06:56. A second hour handles any pending runs that may have timed out or failed.

Responses are saved in Cloudflare KV storage with a one-year retention period, allowing historical comparisons across weeks. Before processing each question, the worker sums up the week's expenses from already saved answers. Once the 2-dollar cap is reached, remaining questions are skipped to protect the API budget from unexpected spikes.

Read alsoChatGPT users report sudden account bans with appeals rejected instantly

Configuring web search and system prompts

Without specific system instructions, the model rarely triggers web search at low effort levels and relies purely on memory, which is useless for newly launched websites. Adding a single line to the system prompt instructs Claude to search the internet first whenever questions involve specific specialists, websites, books, tests, or videos.

API parameters are heavily optimized for cost-efficiency: low effort level and a maximum of two searches per question. If the server pauses a long search turn, the code prompts it to continue up to two times to prevent infinite loops. The specific search country parameter was removed because it caused a 400 error, while the locations remain specified directly within the questions.

Analyzing mentions and avoiding false positives

A site is considered mentioned if its brand name appears in the response text or within citation links. Authors and methodologies are tracked using regular expressions, taking into account JavaScript's limitations with Cyrillic word boundaries. Furthermore, a mention is only credited if the author's name was not already present in the prompt itself.

In addition to tracking brand visibility, the system aggregates all external domains cited by the model. This provides valuable insight into which competing websites appear in AI responses and how often. The validation logic is thoroughly covered by unit tests to ensure accurate filtering of Cyrillic names and prevent false positives.

Why this matters and what it reveals

Regular monitoring of artificial intelligence outputs helps content publishers objectively measure their brand visibility in the era of generative search engines. Because API endpoints with web search differ from standard chat interfaces, these measurements reflect true citation potential rather than isolated chat sessions.

The collected statistics on alternative websites appearing in AI answers allow for manual topic analysis. Based on these insights, the team decides which new pages and articles to write next in order to improve their overall visibility and presence in AI-generated answers.

Source: Все публикации подряд на Хабре

Related articles