Sub topic 2
The tracking workflow: prompts, runs, parsing, metrics
Assume you know basic SEO terms such as keywords, rankings, and backlinks. You should also be comfortable reading simple ratios and percentages. This chapter uses optional Python to show the calculations.
AI visibility tracking is a measurement workflow. You start with representative prompts, run them through one or more AI answer engines, save the raw responses, extract structured observations, and calculate metrics. Each step affects the result. A changing prompt set or an unrecorded model change can make two reporting periods impossible to compare.
1. Define the unit of measurement
A prompt is the question you submit, such as “best CRM for small teams.” Give every prompt a stable ID and record its topic and intent. The ID lets you compare the same question over time.
A run is one execution of one prompt against one engine under recorded conditions. Store at least:
- prompt ID and exact prompt text
- engine, model, and model version when available
- date, time, country, language, and account context
- complete answer text
- every cited URL
- collection method and any error
A run is not the same as a prompt. The same prompt may produce different answers on different runs. Keeping raw responses lets you audit a metric later instead of trusting a dashboard total.
2. Build the prompt set
A useful prompt set represents the questions that matter to the business. Group prompts by topic, search intent, customer stage, and relevant competitors. Include informational questions, comparisons, recommendations, and product-specific questions.
Keep the set stable during a reporting period. If you add prompts, record the change and either recalculate the historical periods or label the new series separately.
| Field | Example | Why it matters |
|---|---|---|
| Prompt ID | crm-001 | Joins results across runs |
| Intent | recommendation | Enables segment reporting |
| Prompt | best CRM for small teams | Preserves the exact input |
| Competitors | Globex, Initech | Supports comparison |
3. Collect repeated runs
Run each prompt more than once when the engine allows it. Record the engine and collection conditions for every run. Do not silently replace failed responses or remove unusual answers. Mark them as errors and report your inclusion rule.
A simple workflow has these stages:
- Load the versioned prompt set.
- Submit each prompt to the selected engine.
- Save the raw answer and cited URLs.
- Parse observations using consistent rules.
- Calculate metrics from the parsed data.
- Review samples manually before publishing a trend.
4. Parse mentions and citations separately
A mention is a recognizable reference to a brand in the answer text. A citation is a source URL attached to the answer. An answer can mention a brand without citing its website, or cite a website without naming the brand in the prose.
Use explicit matching rules. Word-boundary matching avoids counting “Acme” inside an unrelated longer word. Domain matching should normalize www.acme.com and recognize subdomains when that matches your ownership definition.
import re
from collections import Counter
from urllib.parse import urlparse
brands = {"Acme": ["acme"], "Globex": ["globex"], "Initech": ["initech"]}
own_domain = "acme.com"
runs = [
{"answer": "Popular options include Globex and Acme.",
"cited_urls": ["https://www.acme.com/crm"]},
{"answer": "Initech and Globex offer free plans.",
"cited_urls": ["https://example.org/review"]},
{"answer": "Compare pricing and support.",
"cited_urls": []},
]
def mentioned(text, aliases):
return any(re.search(rf"\b{re.escape(a)}\b", text, re.I)
for a in aliases)
def own_url(url):
host = urlparse(url).netloc.lower().removeprefix("www.")
return host == own_domain or host.endswith("." + own_domain)
counts = Counter(
brand for run in runs for brand, aliases in brands.items()
if mentioned(run["answer"], aliases)
)
total = sum(counts.values())
share = {brand: counts[brand] / total if total else 0
for brand in brands}
mention_rate = counts["Acme"] / len(runs)
citation_rate = sum(
any(own_url(url) for url in run["cited_urls"]) for run in runs
) / len(runs)
print(share)
print(mention_rate, citation_rate)5. Calculate and label the metrics
For a selected prompt set:
- Mention rate = runs mentioning your brand divided by eligible runs.
- Citation rate = runs containing at least one citation to your domain divided by eligible runs.
- Share of voice = your brand mentions divided by all counted brand mentions.
State the denominator with every metric. “Citation rate” is ambiguous unless readers know whether it means answers, URLs, prompts, or runs. Also distinguish zero from missing data. A failed collection is not evidence that the brand was absent.
Exercise
Ten eligible runs contain four mentions of Acme and two runs cite acme.com. What are the mention rate and citation rate?
Show answer
The mention rate is 4/10 = 40%. The citation rate is 2/10 = 20%, assuming each run counts once.