Track Google AI Mode Citations: Python Tutorial (2026)
Google AI Mode quietly graduated from "experimental tab" to "default behaviour on a lot of queries" in early 2026. For many of the keywords I care about — SaaS comparisons, developer questions, vendor research — AI Mode is now the first thing the user sees. The blue links are below the fold or hidden behind an "all" tab.
Which means a separate tracking question: am I cited inside Google's conversational answer for my target queries? Not the AI Overview — that's a different surface — the deeper AI Mode synthesis.
This guide is the Python script I run weekly to answer that. Self-contained, ~80 lines, runs on free-tier API credits up to 100 queries, and produces a clean diff against the previous run.
AI Mode vs AI Overviews — the distinction that matters
These are not the same surface and they don't behave the same way.
AI Overviews are short summaries that appear above the organic SERP for a subset of queries. Typically 100–200 words, 1–3 cited sources. Already familiar; you can read our deeper breakdown in the AIO optimization guide.
AI Mode is a separate conversational interface launched as a Search tab and rolled into defaults during 2025–2026. Longer responses, more cited sources, supports follow-up questions, and draws from a wider candidate pool than AIO. The official launch posts on Google's blog describe the user-facing differences in detail.
For brand visibility purposes the consequences are concrete:
- AI Mode cites more sources, so the "appearance probability" is higher per query but per-citation salience is lower.
- AI Mode draws from pages that don't always rank in the top 5 organically — structure and entity signals matter more than raw ranking.
- AI Mode is more recency-sensitive than AIO for a wider range of query categories.
Practical upshot: getting cited in AI Mode is easier than getting cited in an AIO for the same query — if your page is structurally clean and freshly updated.
What the tracker tracks
Three columns per query, per week:
- AI Mode present? — was an AI Mode answer block returned at all
- Self cited? — is your domain in the AI Mode source list
- Position of citation — where in the source list you appear, if at all
And one bonus computed at the run level: share of voice — the percent of tracked queries where your domain is cited in AI Mode.
Prereqs
- Python 3.10+ and
requests - A Serpent API key — sign up free for 100 calls included
- A CSV of tracked queries (one per line)
- 10 minutes
Step 1: Single-query fetcher
Save as aimode_fetch.py:
import os, requests
API_KEY = os.environ["SERPENT_API_KEY"]
URL = "https://apiserpent.com/api/search"
def fetch_aimode(query, country="us"):
"""Return (present, sources) for AI Mode result on a query."""
r = requests.get(URL, params={
"q": query, "num": 10, "country": country, "engine": "google"
}, headers={"X-API-Key": API_KEY}, timeout=120)
r.raise_for_status()
data = r.json().get("results", {})
aimode = data.get("aiMode") or data.get("aiOverview") or {}
sources = aimode.get("sources", [])
return bool(aimode), [s.get("url","") for s in sources]
One thing to note: when AI Mode is not yet rolled out for a query in your country, the API falls back to whichever AI surface Google is showing — usually the AI Overview. The tracker treats both as "AI surface" for tracking continuity. If you want to split them, branch on the field name.
Step 2: Bulk runner
Save as aimode_run.py:
import csv, sys, datetime, time
from aimode_fetch import fetch_aimode
DOMAIN = "yourbrand.com" # change me
def run(queries_csv):
today = datetime.date.today().isoformat()
out = f"aimode-{today}.csv"
with open(queries_csv) as f, open(out, "w", newline="") as g:
w = csv.writer(g)
w.writerow(["date","query","present","self_cited","position","first_3_sources"])
for row in csv.reader(f):
q = row[0].strip()
if not q: continue
try:
present, sources = fetch_aimode(q)
pos = next((i+1 for i, s in enumerate(sources) if DOMAIN in s), None)
w.writerow([today, q, present, pos is not None, pos or "", " | ".join(sources[:3])])
print(today, q, "OK", "cited" if pos else "miss")
except Exception as e:
w.writerow([today, q, "ERR", "", "", str(e)])
print(today, q, "ERR", e)
time.sleep(0.2)
print("wrote", out)
if __name__ == "__main__":
run(sys.argv[1] if len(sys.argv) > 1 else "queries.csv")
Make a queries.csv with one query per line (your tracked keywords), then:
python aimode_run.py queries.csv
You get back aimode-2026-05-27.csv with the day's snapshot. Re-run weekly via cron.
Step 3: Weekly diff
The single-day snapshot is fine. The weekly diff is where insight lives. Save as aimode_diff.py:
import csv, sys, glob, datetime
def load(path):
out = {}
with open(path) as f:
for row in csv.DictReader(f):
out[row["query"]] = row
return out
def diff(old_path, new_path):
a, b = load(old_path), load(new_path)
changed = []
for q in sorted(set(a) | set(b)):
oa = a.get(q, {}).get("self_cited", "")
ob = b.get(q, {}).get("self_cited", "")
if oa != ob:
changed.append({"query": q, "was": oa, "now": ob,
"now_pos": b.get(q, {}).get("position", ""),
"now_sources": b.get(q, {}).get("first_3_sources","")})
for c in changed:
flag = "+ GAINED" if c["now"] == "True" else "- LOST "
print(f"{flag} {c['query']} pos={c['now_pos']}")
if c["now_sources"]:
print(f" top3: {c['now_sources']}")
if __name__ == "__main__":
files = sorted(glob.glob("aimode-*.csv"))
if len(files) < 2:
print("Need at least 2 snapshots to diff")
sys.exit(1)
diff(files[-2], files[-1])
Output looks like:
+ GAINED best vector database 2026 pos=4
top3: example.com/vector | pinecone.io/learn | yourbrand.com/blog/...
- LOST cheap serp api pos=
+ GAINED serpapi alternatives pos=2
top3: yourbrand.com/serpapi-alts | reddit.com/r/saas/... | g2.com/...
Three lines, three actionable signals: a new citation worth celebrating, a lost one worth investigating, a high-position citation worth doubling down on.
How to read the report
Two derived metrics matter more than the raw rows.
1. Share of voice. Of all queries where AI Mode is present, what percent cite your domain? A baseline of 5–15 percent is typical for a new brand; 25–40 percent is strong for an established player. Track quarter over quarter, not week over week — noise dominates at shorter intervals.
2. Stability ratio. Of queries where you were cited last week, what percent are still cited this week? Healthy is > 80 percent. Below that you're probably losing on freshness or being out-cited by a competitor that updated their page.
Playbook for moving the needle
Once you have the data, three plays consistently outperform.
1. Refresh the pages you lost
Pages that drop out of AI Mode citations almost always come back when refreshed with new content. See our freshness study for the data and refresh cadence template.
2. Add schema to gainers
Pages that just gained citations are signal-rich. Adding FAQ schema, HowTo schema, and richer entity markup typically stabilises them at higher citation rates within 2–3 weeks.
3. Identify "almost there" queries
Queries where you appear at positions 4–6 in the AI Mode source list are the lowest-effort wins. A targeted refresh + a small content gain on the specific sub-question is usually enough to bump into the top 3.
For broader brand-side tracking that covers ChatGPT, Claude, Gemini, and Perplexity in one call, see our cross-LLM citation tracker — the AI Rank API powers it.
What I check before declaring a problem
Three quick checks before treating a citation drop as a real problem:
Did the AI Mode answer itself disappear (no surface)? That's not a drop — that's a query that doesn't trigger AI Mode anymore. Different problem.
Did the query intent change? Sometimes Google reinterprets a query (e.g. "apple" shifting from fruit-leaning to product-leaning seasonally). The citation pool changes with intent. Check organic results too.
Did a fresh competitor publish? site:competitor.com 2026 often shows whether a relevant new page launched in the last week. If yes, your refresh is the right response.
FAQ
How is AI Mode different from AI Overviews?
AI Mode is a longer, conversational answer surface with broader source selection; AI Overviews are short summaries above the organic SERP. Different tracking, sometimes different rankings.
Can a SERP API detect AI Mode answers?
Yes. The Serpent Google SERP API returns the AI Mode answer block and its source list in the structured response.
How often should I run the tracker?
Weekly for most brands. Daily during active campaigns, big content pushes, or after algorithm changes.
What if my domain disappears one week and reappears the next?
AI Mode citation variance is higher than organic ranking variance. Track the stability ratio over 4 weeks; week-to-week noise is normal.
Can I track AI Mode across multiple countries?
Yes. Pass country to the fetcher. AI Mode rollouts vary by market, so country differences are real.
Start Tracking AI Mode Citations Today
Serpent's Google SERP API returns AI Mode answer text and source URLs in every web search response. 100 free calls on signup, no card.
Get Your Free API KeyExplore: Google SERP API · AI Rank API · Pricing


