AfriGauge weekly capture methods
Plain-English notes for the three weekly data captures. The raw files live under data/<capture>/<YYYY-MM-DD>/, with the date taken from East Africa Time (Africa/Nairobi, UTC+3). Nothing in those folders is to be edited after it is written. In particular, never adjust numbers.
The election these captures track is Kenya's general election on 10 August 2027. The weekly capture day is Monday morning, East Africa Time. A missed Monday is run as soon as possible the same week, still stored under that later EAT date, not back-dated.
1. AI mirror
What. Each week the same fixed prompts are sent to the same target models, asking who leads the 2027 Kenyan presidential race and the big governor races (Nairobi, Mombasa, Kiambu, Nakuru, Kisumu, plus Machakos and Uasin Gishu, and which governor race is most nationally significant). Every prompt asks for one pick, reasons, and a confidence percentage from 0 to 100. The wording is in ai-mirror/prompts.json and must be used unchanged.
When. Monday morning, East Africa Time. A light run is one pass: each active prompt, once, on each model that can be reached that week.
How it is stored. One JSON object per answer is appended to data/ai-mirror/<YYYY-MM-DD>/records.jsonl, and a copy is also written as its own JSON file. The object holds the prompt id, a hash of the exact prompt text, the model, the model version string the provider reported, the provider, timestamps in both EAT and UTC, the raw answer, a refusal flag, and the run number. Failed calls are stored too, with raw_answer left null and the error recorded. Secrets never go in these files.
Limitations. These records are what the AI said that day, not voter opinion, not a poll, and not a forecast AfriGauge is endorsing. Models make things up, lag behind events, refuse some questions, and can change behaviour when the provider updates them. Free-tier models and web chatbots are rate-limited and may log prompts. ChatGPT web and Claude web have to be captured by hand unless an official API key is later approved. Compare weeks only where the prompt id and prompt text hash are unchanged.
2. Google Trends
What. A fixed list of search terms for major presidential contenders, parties, and key governor names, queried in Kenya only (geo=KE). The list and the batching rules are in trends/terms.json. "William Ruto" is included in every comparison batch so the other terms in that batch share one scale.
When. Monday morning, East Africa Time. Each batch is pulled for the past seven days (now 7-d) and, separately, for the past roughly 90 days (today 3-m) as context. Those two timeframes are stored as different files.
How it is stored. Raw interest-over-time tables, interest-by-region tables if returned, and the request log go in data/trends/<YYYY-MM-DD>/. Numbers are saved exactly as Google Trends returned them. A blocked or empty request is stored as an error, not as a zero.
Limitations. A Trends score is relative search interest, not the number of searches, not vote share, and not public opinion. Scores are only comparable inside the same batch, country, and timeframe. Short names can collide with other meanings. Google has no official Trends API for this; the script uses the public web interface through pytrends, which can be rate-limited or blocked, especially from cloud servers and later from GitHub Actions. When that happens, the failure is the record.
3. Meta Ad Library
What. A weekly snapshot of ads about social issues, elections or politics that reached Kenya, taken from Meta's public Ad Library website and, when a free identity-verified token exists, from Meta's official Ad Library API. The full steps, account requirements, and query shape are in ad-library/method.md.
When. Monday morning, East Africa Time. The API pull covers ads delivered in the previous Monday–Sunday window, plus a snapshot of ads still marked active.
How it is stored. HTTP responses, raw API pages, and a manifest go in data/ad-library/<YYYY-MM-DD>/. Spend and impression figures, when present, are ranges and stay ranges. Tokens and cookies are never written to disk.
Limitations. This is only Meta (Facebook, Instagram, and other Meta placements). It misses every other channel. Classification as a political or issue ad is Meta's, not ours. The public website often hides its data from scripts, and the API will not run until a real person has passed Meta's identity and location check and kept a long-lived token current (tokens typically last about 60 days). The capture records ads that were shown. It is not a poll and not an AI-mirror result.