search-analytics
Collect and analyze Google Search Console organic search data in a local SQLite database. Stores clicks, impressions, click-through rates (CTR), average ranking positions, and landing pages so you can run SQL queries or view performance reports. Activate when analyzing Google Search traffic, tracking keyword rankings, finding SEO content optimization opportunities, or querying Search Console data with SQL.
danicat · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add danicat/skills --skill search-analytics技能说明
name: search-analytics description: > Collect and analyze Google Search Console organic search data in a local SQLite database. Stores clicks, impressions, click-through rates (CTR), average ranking positions, and landing pages so you can run SQL queries or view performance reports. Activate when analyzing Google Search traffic, tracking keyword rankings, finding SEO content optimization opportunities, or querying Search Console data with SQL. license: Apache-2.0 metadata: category: analytics tags: "google-search, analytics, seo, geo, optimization" author: Daniela Petruzalek (daniela@danicat.dev) version: "0.2.0" catalog: https://skills.danicat.dev
Google Search Console SQLite Ingestion & SQL Analytics
The search-analytics skill ingests Google Search Console performance metrics into a local SQLite analytics database (search_analytics.db or $XDG_DATA_HOME/search-analytics/analytics.db) without data loss, preserving all raw JSON payloads, handling API quotas via 25,000 batch chunks, and providing direct SQL querying over indexed search traffic.
Available scripts
scripts/search_analytics.py: Automated sync, reporting, and OAuth CLI for Google Search Console. Executed viauv run scripts/search_analytics.py(requires Google Cloud OAuth credentials).scripts/test_search_analytics.py: Unit and regression test suite validating schema, query extraction, and CLI flags.
⚡ Quick Start & Primary Actions
All operations are driven via the bundled Python script in scripts/search_analytics.py:
# 1. Authenticate with Google OAuth 2.0
uv run scripts/search_analytics.py auth --port 8080
# 2. Incremental Sync (Updates newest days + 3-day latency overlap)
uv run scripts/search_analytics.py sync --db path/to/database.db
# 3. Full Historical Backfill (Ingests up to 16 months of granular daily data)
uv run scripts/search_analytics.py sync --full --db path/to/database.db
# 4. Run Pre-Built SQL Reports
uv run scripts/search_analytics.py report overview --db path/to/database.db
uv run scripts/search_analytics.py report top-queries --db path/to/database.db
uv run scripts/search_analytics.py report top-pages --db path/to/database.db
uv run scripts/search_analytics.py report countries --db path/to/database.db
uv run scripts/search_analytics.py report devices --db path/to/database.db
uv run scripts/search_analytics.py report timing --db path/to/database.db
uv run scripts/search_analytics.py report milestone-impact --db path/to/database.db
# 5. Run Ad-Hoc SQL Query
uv run scripts/search_analytics.py query "SELECT query, SUM(clicks), SUM(impressions) FROM search_performance GROUP BY query ORDER BY SUM(clicks) DESC LIMIT 10" --db path/to/database.db
If --db is omitted, the script defaults to search_analytics.db in the current working directory.
🗄️ Database Schema & Relational Structure
The database maintains 6 relational tables and 7 high-performance analytical views. Detailed DDL and schema definitions are in references/schema.md.
Tables
daily_site_performance: Unfiltered property-level daily totals (dimensions: ['date']). Matches 100% of property clicks/impressions in the Search Console web interface and 28-day Achievement badges.- Key columns:
id(PK),site_url,date,search_type,clicks,impressions,ctr,position,raw_json,synced_at.
- Key columns:
search_performance: Granular keyword-level performance partitioned by query, page, country, and device.- Key columns:
id(PK),site_url,date,query,page,country,device,search_appearance,search_type,clicks,impressions,ctr,position,raw_json,synced_at.
- Key columns:
properties: Verified Search Console web properties.- Key columns:
site_url(PK),permission_level,raw_json,synced_at.
- Key columns:
sitemaps: Submitted XML sitemaps, error counts, and indexed URL counts.- Key columns:
site_url,path(PK),type,last_downloaded,last_submitted,errors,warnings,indexed_count,raw_json,synced_at.
- Key columns:
site_milestones: Release milestones and publication launches for cohort impact analysis.- Key columns:
commit_hash(PK),event_date,title,description,category,scope,author,created_at.
- Key columns:
sync_history: Audit log of backfill and incremental sync operations.- Key columns:
id(PK),site_url,sync_type,start_date,end_date,rows_synced,status,error_message,started_at,completed_at.
- Key columns:
📊 Analytical SQL Views
| View Name | Description | Key Columns |
|---|---|---|
v_search_performance | Granular performance with computed calendar dimensions | date, year_month, day_of_week, query, page, country, device, clicks, impressions, ctr_pct, avg_position |
v_daily_summary | Daily aggregated traffic metrics per site | date, distinct_queries, distinct_pages, total_clicks, total_impressions, avg_ctr_pct, avg_position |
v_top_queries | Aggregated search term rankings & click share | query, active_days, total_clicks, total_impressions, avg_ctr_pct, avg_position |
v_top_pages | Aggregated landing page performance & query breadth | page, ranking_queries, active_days, total_clicks, total_impressions, avg_ctr_pct, avg_position |
v_country_breakdown | Geographic traffic distribution | country, total_clicks, total_impressions, avg_ctr_pct, avg_position |
v_device_breakdown | Desktop vs. Mobile vs. Tablet comparison | device, total_clicks, total_impressions, avg_ctr_pct, avg_position |
v_milestone_impact | Pre vs. Post milestone search traffic cohort impact | milestone_title, milestone_date, cohort, days_tracked, total_clicks, total_impressions, avg_ctr_pct |
🔍 Common SQL Analytics Recipes
Pre-tested SQL query recipes are documented in [references/queries.md](referenc