AdSense Verification & Policy Checker
Verify Google AdSense publisher tags, account ID tags, and authorized
ads.txtdeclarations on any domain in real time.
Technical Architecture: Reverse-Engineering Google AdSense Detection
Validating whether a website is properly configured to serve Google AdSense requires inspecting four critical signals across the server response and rendered DOM:
- Publisher ID markers (
ca-pub-XXXXXXXXXXXXXXXX). - Script tags loading the AdSense client library (
adsbygoogle.js). - Ad slot container elements (
<ins class="adsbygoogle">). - An authorized digital seller record in the domain's root
/ads.txtfile (IAB standard).
The AdSense Checker queries a dedicated serverless function (/api/adsense) to fetch and analyze both the HTML payload and the root ads.txt declaration.
1. Publisher ID Discovery & Pattern Matching
The backend analyzes HTML using regex patterns to discover AdSense account signatures across multiple implementation standards:
// api/adsense.js (Publisher ID extraction extract)
function parseAdSenseSignals(html, origin) {
// 1. Meta Tag: google-adsense-account
const metaTagMatch = html.match(
/<meta[^>]+name=["']google-adsense-account["'][^>]+content=["']([^"']+)["'][^>]*>/i
);
// 2. Client script tag: pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
const scriptRegex = /src=["'](?:https?:)?\/\/pagead2\.googlesyndication\.com\/pagead\/js\/adsbygoogle\.js(?:\?client=ca-pub-(\d+))?["']/i;
const scriptMatch = html.match(scriptRegex);
// 3. Ad Unit container: data-ad-client="ca-pub-..."
const insClientMatch = html.match(/data-ad-client=["']ca-pub-(\d+)["']/i);
// Extract normalized Publisher ID
let publisherId = null;
if (metaTagMatch) publisherId = metaTagMatch[1];
else if (scriptMatch && scriptMatch[1]) publisherId = `ca-pub-${scriptMatch[1]}`;
else if (insClientMatch && insClientMatch[1]) publisherId = `ca-pub-${insClientMatch[1]}`;
return { publisherId, scriptFound: !!scriptMatch, insFound: !!insClientMatch };
}
2. Root ads.txt Parsing & IAB Certification
The Interactive Advertising Bureau (IAB) ads.txt specification prevents counterfeit domain spoofing. Google mandates that publishers list their account record in /ads.txt:
google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0
Where:
google.com: The domain of the ad exchange system.pub-XXXXXXXXXXXXXXXX: The publisher's unique 16-digit account ID.DIRECT: Indicates the publisher controls the domain directly (vsRESELLER).f08c47fec0942fa0: Google's canonical certification authority ID.
The serverless function fetches ${origin}/ads.txt, filters comment lines (#), and checks if the detected publisher ID is authorized.
3. Automated Playwright Script for Dynamic SPA Sites
For websites built on Single Page Application frameworks (Next.js, React, Vue) that inject ads asynchronously after hydration, static HTTP scraping may miss tags.
In my guide on Detecting Google AdSense with Python and Playwright, I engineered this headless browser detection script:
import asyncio
from playwright.async_api import async_playwright
async def verify_adsense_live(url: str):
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
# Listen for ad network network requests
network_calls = []
page.on("request", lambda req: network_calls.append(req.url) if "pagead2" in req.url else None)
await page.goto(url, wait_until="networkidle")
# Query live DOM elements
scripts_count = await page.locator('script[src*="adsbygoogle"]').count()
ins_count = await page.locator('ins.adsbygoogle').count()
print(f"AdSense Scripts: {scripts_count}")
print(f"Ad Units (<ins>): {ins_count}")
print(f"Network Calls: {len(network_calls)}")
await browser.close()
asyncio.run(verify_adsense_live("https://example.com"))
4. AdSense Implementation Checklist
| Signal | Expected Location | Validation Criteria |
|---|---|---|
| Site Verification Meta Tag | <head> | <meta name="google-adsense-account" content="ca-pub-..."> |
| Client Script Loader | <head> or <body> | <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-..."></script> |
| Ad Unit Container | <body> | <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-..." data-ad-slot="..."></ins> |
| Push Trigger | Inline <script> | `(adsbygoogle = window.adsbygoogle |
| Authorized Seller Entry | /ads.txt | google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0 |
5. Client-Side Security & Proxy Data Guarantee
- No Credentials Stored: All URL validations are ephemeral and execute without saving cookies or sessions.
- Safe External Scrapes: Requests do not follow unsafe redirections to private subnets or local hosts.
- Respects Robot Etiquette: The proxy uses dedicated user agents and strict timeout limits.
Get notified about updates to this tool
No spam. Just high-quality updates about new features and guides.
Related Tools
Related Posts
Markdown is a lightweight markup language that allows you to format plain text. It is widely used for documentation, writing articles, and creating web content.
A guide for senior developers on identifying and avoiding off-by-one errors in JavaScript with practical code examples.
Vercel vs GitHub pages comparison in terms of settings, customization and deploying future projects