Skip to main content

Free Rank and AI-Answer Tracker

A free Python script that tracks Google rankings, AI Overviews and whether ChatGPT, Perplexity, Gemini or Claude name your brand, week by week.

Download

Download rank-ai-tracker.zip (7 KB). It contains the Python script, this guide as a README, and example keywords.txt and prompts.txt files. Free to use, copy and change, with no sign-up.

Quick overview

This script takes one snapshot a week of where a brand stands in Google and in AI assistants, and keeps every snapshot so you can see the trend. For each keyword it records the position in the live top 100, the page that ranks, the three domains above everyone else, and whether an AI Overview or a local pack is showing and whether the brand appears in it. For each customer question it asks ChatGPT, Perplexity, Gemini or Claude and records whether the answer names the brand and whether it cites one of the brand’s pages. Each run is a single command and writes a dated folder plus a line in a history file.

Who it’s built for

Agencies and in-house SEOs who report on rankings and are now being asked about AI search as well. It suits a small brand that wants to know if it shows up at all, and an agency running the same check across clients. We run it every week on our own site at Digital Royalty, a UK web and software studio, and this is that script with our names taken out.

What you get

  • serp-summary.csv with one row per keyword: position, ranking URL, top three domains, AI Overview shown and whether it mentions you, local pack shown and whether you’re in it, and the other SERP features on the page.
  • llm-summary.csv with one row per question per assistant: named or not, cited or not, which of your URLs were cited, and how many sources the answer used.
  • Every raw API response saved as JSON. When a new question comes up in three months you can answer it from the files you already have instead of paying for the data again.
  • history.csv, which gains one line per run with the headline counts (keywords ranked, top 10, AI Overviews mentioning you, answers naming you, answers citing you, cost). Rankings and AI answers can’t be backfilled, so a week you miss is gone for good.

What you need to get started

  • A DataForSEO account and your API login and password (from the dashboard, not the account password).
  • Python 3.9 or later, with requests installed.
  • A keyword list (keywords.txt) and a list of questions a customer would put to an assistant (prompts.txt). Both files ship with examples.
  • The brand name, its domain, and any other spellings people use.

Workflow breakdown

  1. Put your keywords in keywords.txt and your customer questions in prompts.txt. Keep both stable from week to week. Add to them, but don’t rename or delete lines, or the history stops lining up.
  2. Set DATAFORSEO_LOGIN and DATAFORSEO_PASSWORD in your environment.
  3. Run it with your brand and domain, for example python rank_ai_tracker.py --brand "Acme Plumbing" --domain acmeplumbing.co.uk --web-search. Add --alias "acme plumbing ltd" for other spellings, --platforms chatgpt,perplexity,gemini,claude to choose assistants, and --location-code / --language for markets outside the UK.
  4. For each keyword the script calls the SERP API (Google Organic, live, depth 100) and checks the result for your domain, AI Overview items and local pack items.
  5. For each question and assistant it calls the AI Optimization API (LLM Responses, live) and checks the answer text for your brand and the cited URLs for your domain.
  6. It writes the dated folder, appends to history.csv, and prints what the run cost.
  7. Schedule it weekly (cron, Task Scheduler, or an n8n Execute Command node) and read the trend once a month. Single weeks move around a lot, so judge a change after it has held for three or four runs.

Cost

A Google SERP at depth 100 costs about $0.013 and an assistant answer costs a fraction of a cent. Thirty keywords and ten questions on two assistants come to roughly $0.50 a run. Our test run of one keyword and one question cost $0.02.

Notes from running it

  • Brand matching is a text match on the raw response, so it survives changes to the API’s item structure. The flip side is that a brand name which is also a common word will over-count. Use the domain and a distinctive alias in that case.
  • The SERP API sometimes returns a transient error for one keyword. The run carries on, lists the failures in failed.txt, and you retry them next week.
  • If an assistant’s default model is retired, python rank_ai_tracker.py --list-models chatgpt shows what the API accepts now, and you change the default at the top of the script.

Where to go next

If the AI answers aren’t naming you, the AEO Content Scorer checks how easily an assistant can lift an answer from a page, and the rest of the free SEO tools cover the on-page side. More templates, checklists and SOP packs are in the resource library. If you’d rather have the tracking set up and read for you, get in touch.

Portrait of Alexander De Sousa, founder of Digital Royalty
Founder-led
“I’ve put everything I know into how this company works — the standards, the method, the care on every project. It runs through the whole team, and I hold us all to it.”

Alexander De Sousa · Founder LinkedIn

Featured on BBC Radio Solent

Get started

Tell us what you need

A few quick questions, then a straight answer from a real person — usually within a few hours.

What happens next

  1. 1 We reply A real person reads your answers and gets back to you, usually within a few hours.
  2. 2 Questions or a short call If anything isn't clear, we ask by email or book a short call. Before any call we audit your website and make the quick fixes it finds, free.
  3. 3 Your fixed quote A clear, fixed price in writing, within 48 hours of any call. There is no obligation to go ahead.

Tell us what you're working on

Whether it's a new site, a platform, or a process that shouldn't be manual any more — we'll tell you honestly if we can help.