google-analytics

Pull GA4 reports, traffic data, and insights from the Google Analytics Data API. Use when asked about website traffic, user behavior, acquisition channels, conversions, or audience segments. Trigger phrases: "google analytics", "GA4", "traffic report", "analytics data", "user acquisition", "engageme

By openclaudia · 469 installs

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

Source repository · Upstream listing

Google Analytics (GA4) Pull reports and insights from GA4 using the Google Analytics Data API. Prerequisites Requires Google OAuth credentials: GOOGLE CLIENT ID GOOGLE CLIENT SECRET A valid OAuth access token (refreshed as needed) Set credentials in .env , .env.local , or ~/.claude/.env.global . Getting an Access Token Store the refresh token securely. The access token expires after 1 hour. Finding Your GA4 Property ID The property ID format is properties/XXXXXXXXX . API Base All report requests use POST with a JSON body. Always include Authorization: Bearer {ACCESS TOKEN} . 1. Traffic Overview Report Get sessions, users, page views, and engagement rate over a date range. Example curl Date Range Shortcuts today , yesterday 7daysAgo , 14daysAgo , 28daysAgo , 30daysAgo , 90daysAgo Specific dates: 2024 01 01 Compare periods by passing two dateRanges 2. User Acquisition Report See where users come from (channels, sources, campaigns). Useful Acquisition Dimensions Dimension Description sessionDefaultChannelGroup Channel grouping (Organic, Paid, Social, etc.) sessionSource Traffic source (google, facebook, etc.) sessionMedium Medium (organic, cpc, referral, etc.) sessionCampaignName UTM campaign name firstUserSource First touch attribution source 3. Top Pages Report Find the highest traffic pages on the site. 4. Engagement Metrics Understand how users interact with your content. Key Engagement Metrics Metric What It Measures engagementRate % of sessions that were engaged ( 10s, 2+ pages, or conversion) averageSessionDuration Mean session length in seconds screenPageViewsPerSession Pages per session bounceRate % of sessions with no engagement eventCount Total events fired 5. Conversion Tracking Report on conversion events (purchases, signups, etc.). Conversion by Channel 6. Audience Segments Break down traffic by device, geography, and demographics. By Device Category By Country Replace deviceCategory with country in the dimensions. By Landing Page + Source 7. Period Comparison Compare two time periods to identify trends. Response Parsing GA4 API returns JSON. Parse with python3 or jq: Workflow: Monthly Analytics Report When asked for a monthly report: 1. Pull traffic overview (sessions, users, page views) with period comparison 2. Pull acquisition breakdown by channel 3. Pull top 20 pages by page views 4. Pull conversion summary by channel 5. Pull device and country breakdown Present as a structured report with tables, trends (up/down arrows), and recommendations: Common Issues 403 Forbidden : User lacks access to the GA4 property Empty rows : No data for the requested date range or filters Quota exceeded : GA4 API has daily quotas; reduce date ranges or batch requests Property not found : Verify the property ID format ( properties/XXXXXXXXX )