Sub topic 2
The tracking workflow: prompts, runs, parsing, metrics
This chapter covers how an AI visibility tracking tool turns a list of questions into numbers. It assumes you know what AI answer engines are and how they differ from rank-based search. It also assumes you are comfortable with ratios and percentages. The Python example is optional, but it makes each stage concrete.
Why a workflow, not a lookup
A traditional rank tracker asks one question: where does this URL appear for this keyword? An AI answer engine returns generated text, so there is no ranked list to read a position from. The tool has to ask the engine questions, save what comes back, and measure it.
Every tracking tool does this in four stages:
- Prompts. A fixed set of questions to ask.
- Runs. Sending each prompt to each engine, usually several times, and saving the raw response.
- Parsing. Extracting structured facts from the raw text: which brands were named, which URLs were cited, in what order.
- Metrics. Aggregating those facts into rates and shares that you can chart over time.
Dashboards often hide these stages. Knowing them tells you where a number came from and where it can go wrong.
Stage 1: the prompt set
The prompt set is the tool's sample of the questions your customers might ask. Each entry normally carries more than the question text:
- A stable prompt ID, so results stay comparable when you edit wording elsewhere.
- A topic or product category and an intent label (for example comparison, how-to, or purchase).
- Optional market fields such as country and language, because answers differ by location.
The prompt set is the most consequential choice in the workflow. Every later metric is computed over it, so a metric describes only the questions you chose. A set that is full of questions naming your own brand will make you look strong. A set made only of generic questions may understate you. Building a representative set is covered in its own chapter. Here, treat the set as fixed input and change it deliberately, not casually, because changing it breaks comparison with earlier periods.
Stage 2: runs
A run is one prompt sent to one engine at one moment, producing one response. The same prompt will not always produce the same answer. Generation involves randomness, and engines also change models, retrieval sources, and formatting without notice. So tools schedule several runs of each prompt, often daily or weekly, and treat each as a sample, not as the truth.
A useful run record stores at least:
| Field | Why it matters |
|---|---|
| Prompt ID | Links the response back to the prompt set |
| Engine and model label | Results from different engines should not be silently merged |
| Run index and timestamp | Lets you analyze repeats and trends |
| Raw answer text | Lets you re-parse later with better rules |
| Cited URLs, in order | Citations are often separate from the answer text |
| Location and language settings | Needed to interpret differences between markets |
The most useful habit is to store the raw response and treat parsing as a separate, repeatable step. If your brand matching has a bug, or you add a competitor later, you can re-parse stored text instead of paying to collect it again. Some tools keep only the computed metrics. Then a parsing error cannot be corrected after the fact.
How the response is actually obtained, through an official API or by capturing the engine's user interface, affects what you get back and how closely it matches what real users see. That has its own chapter. For now, note that this stage is where the data's realism is decided.
Stage 3: parsing
Parsing converts free text into records you can count. There are two main extraction jobs.
Mention detection. For each tracked brand, decide whether the answer names it. Tools keep a list of aliases per brand and search the answer for them. Word-boundary matching matters. Without it, a brand called "Apex" would match inside "apex predator", and a short alias could match inside longer words. Case-insensitive matching handles "ACME" and "Acme". Aliases cover product names, abbreviations, and common spellings.
Citation extraction. Pull the URLs the engine listed as sources, then reduce each to a host so you can group by domain. Normalizing the host (lowercase, strip a leading www.) prevents www.acme.com and acme.com from counting as different sites. Checking whether a host is your own domain should also accept subdomains such as docs.acme.com, but should not accept notacme.com. A naive "ends with acme.com" check gets that last case wrong, which is why the check below compares to the domain exactly or requires a leading dot.
Parsing can also record position (which brand came first) and tone toward each brand. Those are later chapters. The key point here is that parsing is rule-based or model-assisted, so it makes mistakes, and those mistakes flow straight into the metrics.
Stage 4: metrics
Metrics are aggregations over parsed runs. The three core ones, each with a denominator you should always be able to name:
- Mention rate: runs in which a brand is named, divided by total runs.
- Citation rate: runs in which at least one cited URL belongs to your domain, divided by total runs.
- Share of voice: your mention count divided by the total mention count of all tracked brands.
The denominators differ. Mention rate and citation rate use runs. Share of voice uses mentions across brands. A run that names three brands adds three to the share-of-voice denominator but only one to the run count. Share of voice therefore depends on which competitors you track. Adding a competitor lowers your share even if nothing about your own visibility changed. Later chapters treat share of voice in detail. The point for now is that every figure is a ratio, and a ratio is only meaningful with its denominator stated.
A minimal end-to-end pipeline
The following script runs all four stages against a stub engine so it needs no network or API key. The collect function stands in for a real engine call. Everything after it, including the record structure, parsing, and metric calculations, works the same on real responses.
import re
from dataclasses import dataclass, field
from datetime import datetime, timezone
from urllib.parse import urlparse
BRANDS = {"Acme": ["acme"], "Globex": ["globex"], "Initech": ["initech"]}
OWN_DOMAIN = "acme.com"
# Stage 1: a fixed prompt set
PROMPTS = {
"p1": "best crm for small teams",
"p2": "crm with free plan",
}
# Canned engine behaviour: two possible answers per prompt, to mimic variability
CANNED = {
"p1": [
("Popular options include Globex and Acme.",
["https://www.acme.com/crm", "https://example.org/review"]),
("Globex is a common choice.", ["https://example.org/review"]),
],
"p2": [
("Initech and Globex both offer free plans.", ["https://example.org/review"]),
("Initech offers a free plan.", []),
],
}
@dataclass
class Run:
prompt_id: str
engine: str
run_index: int
collected_at: str
answer: str
cited_urls: list = field(default_factory=list)
# Stage 2: runs (stubbed; a real tool would call an engine here)
def collect(prompt_id, engine, run_index):
answer, urls = CANNED[prompt_id][run_index % 2]
stamp = datetime.now(timezone.utc).isoformat()
return Run(prompt_id, engine, run_index, stamp, answer, urls)
# Stage 3: parsing
def host(url):
h = urlparse(url).netloc.lower()
return h[4:] if h.startswith("www.") else h
def is_own_domain(h):
return h == OWN_DOMAIN or h.endswith("." + OWN_DOMAIN)
def parse(run):
mentioned = {
brand
for brand, aliases in BRANDS.items()
if any(re.search(rf"\b{re.escape(a)}\b", run.answer, re.IGNORECASE)
for a in aliases)
}
hosts = {host(u) for u in run.cited_urls}
return {"mentioned": mentioned, "hosts": hosts}
runs = [
collect(pid, "stub-engine", i)
for pid in PROMPTS
for i in range(3) # three repeats per prompt
]
parsed = [parse(r) for r in runs]
# Stage 4: metrics
n = len(parsed)
for brand in BRANDS:
rate = sum(brand in p["mentioned"] for p in parsed) / n
print(f"{brand} mention rate: {rate:.0%}")
own_cited = sum(any(is_own_domain(h) for h in p["hosts"]) for p in parsed) / n
print(f"own-domain citation rate: {own_cited:.0%}")The output is:
Acme mention rate: 33%
Globex mention rate: 83%
Initech mention rate: 50%
own-domain citation rate: 33%Six runs went in: two prompts times three repeats. Acme was named in two of them, which gives 33%. Notice that the three mention rates add up to more than 100%. That is correct, because one answer can name several brands.
Edge cases and failure points
Each stage has typical ways to fail. Knowing them tells you where to look when a number surprises you.
| Stage | Typical failure | Effect on metrics |
|---|---|---|
| Prompts | Set skewed toward branded or easy questions | Visibility looks better or worse than it is for real users |
| Runs | Too few repeats, or runs bunched into one moment | Rates swing from noise, not from real change |
| Runs | Engine or model silently changes | A trend break that looks like a result of your work |
| Parsing | Missing alias, or substring matching without word boundaries | Mention rate too low, or false positives |
| Parsing | Citation URLs with redirects or tracking parameters | Same page counted as several sources, or own domain missed |
| Metrics | Denominator changes (new competitor, new prompts) | Share of voice moves with no change in your visibility |
Two further points matter in practice. First, an answer may mention a brand without citing it, or cite a brand's page without naming it. Both are legitimate outcomes, so track them separately. Second, an empty response, a refusal, or an error is still a run. Decide in advance whether failed runs are excluded or counted as no mention, and apply that rule consistently. Otherwise a rate limit on the engine's side shows up as a visibility drop.
What the workflow does not give you
The workflow produces a sample-based estimate. It does not give a complete count of how often real users see your brand. Because runs are samples, a single rate carries uncertainty, and later chapters show how to report it with an interval. The prompt set stands in for real demand, and the quality of that stand-in sets a ceiling on the metrics.
Exercise
A tool tracks three brands over 20 runs. Your brand is named in 5 runs, Competitor A in 10 runs, and Competitor B in 5 runs. Compute your mention rate and your share of voice. Then explain what happens to each if you add a fourth tracked competitor that is named in 10 runs and nothing else changes.
Show answer
Mention rate is runs naming you divided by total runs: 5 / 20 = 25%. Share of voice is your mentions divided by all tracked mentions: 5 / (5 + 10 + 5) = 5 / 20 = 25%. After adding the fourth competitor, your mention rate is still 5 / 20 = 25%, because its denominator is the number of runs. Your share of voice falls to 5 / 30, about 17%, because the total mentions grow to 30. Your visibility did not change, but the denominator of share of voice depends on which competitors you track.
Exercise
A parsing rule for own-domain citations is written as url_host.endswith("acme.com"). Name one URL host this wrongly counts as your own, and give a rule that fixes it.
Show answer
The host notacme.com ends with "acme.com", so it is wrongly counted. The fix is to accept only an exact match or a subdomain: h == "acme.com" or h.endswith(".acme.com"), after lowercasing the host and removing any leading "www.".
Exercise
Your mention rate drops from 40% to 25% between two weekly reports. List three causes in the measurement workflow, not in real-world visibility, that you should rule out before acting on the drop.
Show answer
Any three of these: the prompt set or its weighting changed; the number of repeats per prompt changed or was too small, so the difference is run-to-run noise; the engine or model changed its behavior; failed or empty runs were counted differently; the alias list or parsing code changed; or the data collection method changed, for example from API to interface capture.