How to Check Your Brand's AI Visibility Using Python

AI SEO
Brand Visibility
GEO
Python for SEO
ChatGPT
LLM Optimization

Google is no longer the only place people search. Millions now ask ChatGPT, Claude, Gemini, and Perplexity for recommendations. If your brand isn’t showing up in those answers, you’re invisible to a growing segment of your audience. Here’s how I built a simple tracker to measure it.

Why AI Visibility Matters for SEO in 2025

Traditional SEO tracks keyword rankings on Google. But when someone asks ChatGPT “Who are the best online Hindi class providers?” — does your brand get mentioned? That’s AI Visibility, and it’s becoming a critical metric for every digital marketer.

This is now being called GEO — Generative Engine Optimization. Just like we optimised for search engines, we now need to optimise for large language models (LLMs). As an SEO professional, I built a lightweight Python script to audit exactly this — and I’m sharing the full approach here.

“If your brand isn’t mentioned when an AI answers your customer’s question, you’ve lost that touchpoint — silently.”

What This Script Does

The script sends a set of targeted prompts to the OpenAI API (GPT model) — the same prompts your potential customers might type — and logs the full responses. It then checks whether your brand name appears in those responses and exports everything to an Excel file for analysis.

Think of it as a rank tracker — but for AI answers.

Prerequisites: What You Need

1Python 3.9+ installed on your machine
2An OpenAI API key — get one at platform.openai.com
3Install required libraries by running this in your terminal:

pip3 install openai pandas openpyxl

Step 1: Set Up Your Project Folder

Open your terminal and create a dedicated folder for this project:

mkdir ~/Documents/ai-visibility-tracker
cd ~/Documents/ai-visibility-tracker
touch tracker.py
open -e tracker.py

This creates a new directory, navigates into it, creates your Python file, and opens it in TextEdit for editing.

Step 2: The Complete Tracker Script

Paste this into your tracker.py file. Replace YOUR_API_KEY_HERE with your actual OpenAI key, and update the brand name and prompts to match your business:

import openai
import pandas as pd
import datetime

# ── Configuration ─────────────────────────────────────────
openai.api_key = "YOUR_API_KEY_HERE"
client = openai.OpenAI(api_key=openai.api_key)

BRAND_NAME = "wizmantra"   # lowercase for case-insensitive matching

# ── Prompts to test (customise these for your brand) ──────
prompts = [
    "What is WizMantra?",
    "Who are the top online English class providers?",
    "Tell me about Hindi classes in the UAE.",
    "Which companies offer Sanskrit language courses online?"
]

# ── Main tracking loop ────────────────────────────────────
records = []

for prompt in prompts:
    try:
        response = client.chat.completions.create(
            model="gpt-3.5-turbo",      # switch to "gpt-4" if available
            messages=[{"role": "user", "content": prompt}],
            temperature=0.7
        )
        answer = response.choices[0].message.content

        # Check if brand is mentioned in the AI's response
        brand_visible = "Yes" if BRAND_NAME in answer.lower() else "No"

        records.append({
            "date":          datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            "prompt":        prompt,
            "response":      answer,
            "brand_visible": brand_visible
        })

    except Exception as e:
        records.append({
            "date":          datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            "prompt":        prompt,
            "response":      f"Error: {e}",
            "brand_visible": "Error"
        })

# ── Export results to Excel ───────────────────────────────
df = pd.DataFrame(records)
df.to_excel("ai_visibility_log.xlsx", index=False)

print("✅ Done! Results saved to ai_visibility_log.xlsx")

Step 3: Run the Script

Save the file, then go back to your terminal and run:

python3 tracker.py

You’ll see: ✅ Done! Results saved to ai_visibility_log.xlsx

Open the Excel file — it will look something like this:

Date Prompt Response (truncated) Brand Visible
2026-01-06 10:49 What is WizMantra? WizMantra is an online language learning platform… Yes
2026-01-20 11:01 Who are the top online English class providers? Some popular platforms include Coursera, Preply… No
2026-02-18 12:46 Tell me about Hindi classes in the UAE. Several institutes offer Hindi classes in the UAE… No
2026-02-18 12:47 Which companies offer Sanskrit language courses online? WizMantra is one platform that offers Sanskrit… Yes

How to Interpret Your Results

The Brand Visible column is your core metric. Here’s how to think about it:

  • Direct brand prompts (e.g. “What is WizMantra?”) should almost always return “Yes”. If not, your brand has zero footprint in the AI’s training data — a serious signal.
  • Category prompts (e.g. “top online English class providers”) showing “No” means competitors are capturing those AI-generated recommendations instead of you.
  • Run this script monthly to track improvements over time as you build more content and citations.
💡 Pro Tip: The prompts you choose matter enormously. Think like your customer — what would they literally type into ChatGPT? Use your keyword research data to inform your AI visibility prompts. The overlap between SEO keyword intent and LLM prompt intent is your goldmine.

How to Improve Your AI Visibility (GEO)

Once you know where you’re invisible, here’s how to fix it:

  • Build authoritative content — LLMs are trained on the web. The more high-quality, well-cited content exists about your brand, the more likely it surfaces.
  • Get mentioned on third-party sites — Wikipedia, industry directories, review platforms, and news sites all feed AI training data.
  • Use structured data (Schema markup) — Helps AI systems understand your brand’s entity clearly.
  • Answer specific questions — Write detailed FAQ and “best of” style content that mirrors how users phrase questions to AI.
  • Build brand signals — Consistent NAP (Name, Address, Phone), social profiles, and press coverage all build brand entity strength.

Scaling This Further

This script is a solid foundation. Here’s how you can extend it:

  • Test across multiple AI models — OpenAI, Claude (Anthropic API), Gemini — since each has different training data.
  • Add a sentiment column — not just whether your brand is mentioned, but how positively.
  • Schedule it with cron on Mac/Linux to run weekly automatically.
  • Feed results into Google Sheets for a live dashboard.
About the Author: I’m Ram Shukla, an SEO strategist focused on helping brands grow their digital presence — now including AI-driven search. This script came out of my own need to track a client’s visibility across AI platforms, and I’ve been refining it since September 2025. Have questions or want a custom version built for your brand? Get in touch.

Categories

About The Author

Ram Shukla

Digital Marketing Consultant

With 9 years of marketing experience in planning and executing performance-based digital marketing strategies I helped small and medium size companies grow their revenue, acquire new customers, drive more leads and improve marketing ROI.
Are you looking to grow your business with digital marketing?