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. Supports custom date ranges and filtering.
79
99%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Query GA4 properties for analytics data: page views, sessions, users, traffic sources, conversions, and more.
GA4_PROPERTY_ID - Your GA4 property ID (numeric, e.g., "123456789")GOOGLE_CLIENT_ID - OAuth client IDGOOGLE_CLIENT_SECRET - OAuth client secretGOOGLE_REFRESH_TOKEN - OAuth refresh token (from initial auth flow)python3 scripts/ga4_query.py --metric sessions --dimension date --limit 1python3 scripts/ga4_query.py --metric screenPageViews --dimension pagePath --limit 30python3 scripts/ga4_query.py --metrics screenPageViews,sessions,totalUsers --dimension pagePath --limit 20python3 scripts/ga4_query.py --metric sessions --dimension sessionSource --limit 20python3 scripts/ga4_query.py --metric sessions --dimension landingPage --limit 30python3 scripts/ga4_query.py --metric sessions --dimension pagePath --start 2026-01-01 --end 2026-01-15python3 scripts/ga4_query.py --metric screenPageViews --dimension pagePath --filter "pagePath=~/blog/"python3 scripts/ga4_query.py --metrics sessions,totalUsers --dimension deviceCategorypython3 scripts/ga4_query.py --metric sessions --dimension country --limit 15Common metrics: screenPageViews, sessions, totalUsers, newUsers, activeUsers, bounceRate, averageSessionDuration, conversions, eventCount
Full reference: https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#metrics
Common dimensions: pagePath, pageTitle, landingPage, sessionSource, sessionMedium, sessionCampaignName, country, city, deviceCategory, browser, date
Full reference: https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#dimensions
Default: Table format
Add --json for JSON output
Add --csv for CSV output
GOOGLE_REFRESH_TOKEN and update the environment variable.GA4_PROPERTY_ID is the numeric ID only (e.g., 123456789), not the measurement ID (G-XXXXXXXX). Find it in GA4 under Admin → Property Settings.