跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
数据与分析

google-analytics

Collect and analyze Google Analytics 4 (GA4) website data in a local SQLite database. Stores pageviews, active users, reading dwell time, traffic sources, and outbound clicks so you can run SQL queries or view reports on site performance. Activate when analyzing website traffic, measuring reader engagement and dwell time, evaluating the impact of site updates or milestones, or querying Google Analytics with SQL.

danicat · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add danicat/skills --skill google-analytics

技能说明


name: google-analytics description: > Collect and analyze Google Analytics 4 (GA4) website data in a local SQLite database. Stores pageviews, active users, reading dwell time, traffic sources, and outbound clicks so you can run SQL queries or view reports on site performance. Activate when analyzing website traffic, measuring reader engagement and dwell time, evaluating the impact of site updates or milestones, or querying Google Analytics with SQL. license: Apache-2.0 metadata: category: analytics tags: "ga4, analytics, traffic, metrics, optimization" author: Daniela Petruzalek (daniela@danicat.dev) version: "0.2.0" catalog: https://skills.danicat.dev

Google Analytics 4 SQLite Ingestion & SQL Analytics

The google-analytics skill ingests Google Analytics 4 (GA4) traffic, reading depth, acquisition channels, event streams, and outbound clicks into a local SQLite analytics database (google_analytics.db or $XDG_DATA_HOME/google-analytics/analytics.db) without data loss, preserving raw JSON payloads on all records, and providing a fast SQL interface for website analytics.

Available scripts

  • scripts/google_analytics.py: Automated sync, reporting, and annotation CLI for Google Analytics 4. Executed via uv run scripts/google_analytics.py (requires Google Cloud ADC or OAuth credentials).
  • scripts/test_google_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 CLI script:

# 1. Authorize OAuth 2.0 (with analytics.edit & readonly scopes)
uv run scripts/google_analytics.py auth --port 8080

# 2. Discover accessible GA4 properties
uv run scripts/google_analytics.py properties

# 3. Create Deployment / Milestone Annotation (Cloud API + Local SQLite)
uv run scripts/google_analytics.py annotate \
  --title "Major Release / Architecture Overhaul" \
  --date 2026-08-18 \
  --commit abc1234 \
  --description "Milestone description and release context."

# 4. Incremental Sync (Updates newest days + 3-day latency lookback overlap)
uv run scripts/google_analytics.py sync --db path/to/database.db

# 5. Full Historical Backfill (Ingests up to 14 months of daily granular data)
uv run scripts/google_analytics.py sync --full --db path/to/database.db

# 6. Run Pre-Built Reports
uv run scripts/google_analytics.py report overview --db path/to/database.db
uv run scripts/google_analytics.py report top-pages --db path/to/database.db
uv run scripts/google_analytics.py report channels --db path/to/database.db
uv run scripts/google_analytics.py report geo --db path/to/database.db
uv run scripts/google_analytics.py report events --db path/to/database.db
uv run scripts/google_analytics.py report outbound --db path/to/database.db
uv run scripts/google_analytics.py report milestone-impact --db path/to/database.db

# 7. Execute Ad-Hoc SQL Query
uv run scripts/google_analytics.py query "SELECT page_path, total_views, total_users, avg_dwell_sec, avg_bounce_pct FROM v_page_performance LIMIT 10" --db path/to/database.db

If --db is omitted, the script defaults to google_analytics.db in the current working directory.


🗄️ Database Schema & Relational Structure

The database maintains 7 relational tables and 7 analytical views. Detailed DDL and schema definitions are in references/schema.md.

Tables

  1. daily_pages: Granular daily page metrics by URL, country, device, and traffic source.
    • Key columns: id (PK), property_id, date, page_path, page_title, country, device_category, source_medium, screen_page_views, active_users, sessions, user_engagement_duration, bounce_rate, raw_json, synced_at.
  2. daily_traffic: Acquisition channels and source/medium pairs.
    • Key columns: id (PK), property_id, date, session_source_medium, session_default_channel_group, country, device_category, sessions, active_users, new_users, engaged_sessions, user_engagement_duration, bounce_rate, raw_json, synced_at.
  3. daily_events: User interaction event stream (scroll, click, first_visit, user_engagement, page_view).
    • Key columns: id (PK), property_id, date, event_name, page_path, country, device_category, event_count, total_users, raw_json, synced_at.
  4. outbound_clicks: External link exit destinations and click counts.
    • Key columns: id (PK), property_id, date, link_url, page_path, country, event_count, total_users, raw_json, synced_at.
  5. properties: Verified GA4 property metadata, timezone, and settings.
    • Key columns: property_id (PK), name, account_id, display_name, industry_category, time_zone, currency_code, service_level, raw_json, last_synced_at.
  6. site_milestones: Release milestones and publication events.
    • Key columns: commit_hash (PK), event_date, title, description, category, scope, author, created_at.
  7. sync_history: Audit log of sync executions and row counts.
    • Key columns: id (PK), property_id, sync_type, start_date, end_date, pages_synced, traffic_synced, events_synced, outbound_synced, status, error_message, started_at, finished_at.

📊 Analytical SQL Views

View NameDescriptionKey Columns
v_daily_summaryDaily aggregated traffic metricsdate, total_sessions, total_active_users, total_page_views, total_engagement_min, avg_bounce_pct
v_page_performancePage rollup with views, active users, dwell time, and bounce ratepage_path, page_title, total_views, total_users, total_sessions, avg_dwell_sec, total_dwell_min, avg_bounce_pct
v_channel_performanceAcquisition channel breakdownchannel_group, source_medium, total_sessions, total_users, total_new_users, `total_en
阅读完整来源 ↗