Agent skill
ga4
Query Google Analytics 4 (GA4) data via the Analytics Data API. Use when you need to pull website analytics like top pages, traffic sources, user counts, sessions, conversions, or any GA4 metrics/dimensions.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ga4-archived-2026-01-29
SKILL.md
GA4 - Google Analytics 4 Data API
Query GA4 properties for analytics data: page views, sessions, users, traffic sources, conversions, and more.
Setup
Required Environment Variables
Add to .env:
GA4_PROPERTY_ID=your-property-id
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REFRESH_TOKEN=your-refresh-token
Setup Steps
- Enable API: Google Analytics Data API
- Find Property ID: GA4 Admin → Property Settings → Property ID (numeric)
- Create OAuth: Google Cloud Console → APIs & Services → Credentials
- Get Refresh Token: Run initial auth flow
Commands
Top Pages (by pageviews)
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric screenPageViews \
--dimension pagePath \
--limit 30
Top Pages with Sessions & Users
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metrics screenPageViews,sessions,totalUsers \
--dimension pagePath \
--limit 20
Traffic Sources
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric sessions \
--dimension sessionSource \
--limit 20
Landing Pages
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric sessions \
--dimension landingPage \
--limit 30
Custom Date Range
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric sessions \
--dimension pagePath \
--start 2026-01-01 \
--end 2026-01-28
Filter by Page Path (Blog Posts)
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric screenPageViews \
--dimension pagePath \
--filter "pagePath=~/blog/"
Track Specific Article Performance
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metrics screenPageViews,sessions,totalUsers,bounceRate \
--dimension date \
--filter "pagePath=/blog/waldorf-vs-montessori" \
--start 2026-01-28 \
--end 2026-02-28
Available Metrics
| Metric | Description |
|---|---|
screenPageViews |
Total page views |
sessions |
Number of sessions |
totalUsers |
Total unique users |
newUsers |
First-time visitors |
activeUsers |
Users with engagement |
bounceRate |
Single-page session rate |
averageSessionDuration |
Avg time on site |
conversions |
Goal completions |
eventCount |
Total events |
Available Dimensions
| Dimension | Description |
|---|---|
pagePath |
URL path |
pageTitle |
Page title |
landingPage |
Entry page |
sessionSource |
Traffic source |
sessionMedium |
Traffic medium |
sessionCampaignName |
Campaign name |
country |
Visitor country |
city |
Visitor city |
deviceCategory |
Desktop/Mobile/Tablet |
browser |
Browser name |
date |
Date |
Output Formats
# Default: Table format
python3 scripts/ga4_query.py --metric sessions --dimension pagePath
# JSON output
python3 scripts/ga4_query.py --metric sessions --dimension pagePath --json
# CSV output
python3 scripts/ga4_query.py --metric sessions --dimension pagePath --csv
SEO Content Tracking
After Publishing New Content
Track article performance over time:
# Week 1: Check initial traffic
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metrics screenPageViews,sessions,bounceRate \
--dimension date \
--filter "pagePath=/blog/waldorf-vs-montessori" \
--start 2026-01-28 \
--end 2026-02-04
# Compare to similar content
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric screenPageViews \
--dimension pagePath \
--filter "pagePath=~/blog/" \
--limit 20
Monthly SEO Report
# Top organic landing pages
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metrics sessions,totalUsers,bounceRate \
--dimension landingPage \
--filter "sessionSource=google" \
--limit 30
# Traffic by source
python3 .claude/skills/ga4/scripts/ga4_query.py \
--metric sessions \
--dimensions sessionSource,sessionMedium \
--limit 20
Integration Notes
- Credentials shared with GSC skill
- Data is near real-time (unlike GSC's 3-day delay)
- Use with
seo-content-productionskill for performance tracking
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?