ga4

$npx mdskill add jdrhyne/agent-skills/ga4

Queries Google Analytics 4 (GA4) data for website analytics

  • Fetches top pages, sessions, users, traffic sources, and landing pages.
  • Depends on the Analytics Data API and OAuth credentials setup.
  • Decides by querying GA4 metrics like screenPageViews, sessions, totalUsers, sessionSource, and landingPage.
  • Delivers results in custom date ranges through command-line scripts.

SKILL.md

.github/skills/ga4View on GitHub ↗
---
name: ga4
description: 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.
metadata: {"clawdbot":{"emoji":"📊","requires":{"bins":["python3"]}}}
---

# GA4 - Google Analytics 4 Data API

Query GA4 properties for analytics data: page views, sessions, users, traffic sources, conversions, and more.

## Setup (one-time)

1. Enable Google Analytics Data API: https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com
2. Create OAuth credentials or use existing Google Cloud project
3. Set environment variables:
   - `GA4_PROPERTY_ID` - Your GA4 property ID (numeric, e.g., "123456789")
   - `GOOGLE_CLIENT_ID` - OAuth client ID
   - `GOOGLE_CLIENT_SECRET` - OAuth client secret
   - `GOOGLE_REFRESH_TOKEN` - OAuth refresh token (from initial auth flow)

## Common Queries

### Top Pages (by pageviews)
```bash
python3 scripts/ga4_query.py --metric screenPageViews --dimension pagePath --limit 30
```

### Top Pages with Sessions & Users
```bash
python3 scripts/ga4_query.py --metrics screenPageViews,sessions,totalUsers --dimension pagePath --limit 20
```

### Traffic Sources
```bash
python3 scripts/ga4_query.py --metric sessions --dimension sessionSource --limit 20
```

### Landing Pages
```bash
python3 scripts/ga4_query.py --metric sessions --dimension landingPage --limit 30
```

### Custom Date Range
```bash
python3 scripts/ga4_query.py --metric sessions --dimension pagePath --start 2026-01-01 --end 2026-01-15
```

### Filter by Page Path
```bash
python3 scripts/ga4_query.py --metric screenPageViews --dimension pagePath --filter "pagePath=~/blog/"
```

## Available Metrics

Common metrics: `screenPageViews`, `sessions`, `totalUsers`, `newUsers`, `activeUsers`, `bounceRate`, `averageSessionDuration`, `conversions`, `eventCount`

## Available Dimensions

Common dimensions: `pagePath`, `pageTitle`, `landingPage`, `sessionSource`, `sessionMedium`, `sessionCampaignName`, `country`, `city`, `deviceCategory`, `browser`, `date`

## Output Formats

Default: Table format
Add `--json` for JSON output
Add `--csv` for CSV output

More from jdrhyne/agent-skills

SkillDescription
auto-updaterAutomatically update OpenClaw and selected skills once daily. Runs via cron, checks for updates, applies them, and messages the user with a summary of what changed.
autoresearch-loopDomain-agnostic metric-driven improvement loop, generalizing Karpathy's autoresearch. Use when you want an agent to discover what to measure for a project/goal, then run a keep-or-revert experiment loop that proposes changes, measures them against an objective, keeps wins, discards regressions, and records implemented improvements. Adapts to code perf-auditing, codegen, bug-finding, ad optimization, or any artifact + measurable objective + trial. Trigger: 'autoresearch this', 'find and implement improvements to X', 'discover metrics and optimize'.
clawdbot-release-checkCheck for new OpenClaw releases and notify once per new version.
clawddocsOpenClaw documentation expert with decision tree navigation, search scripts, doc fetching, version tracking, and config snippets for all OpenClaw features
command-creatorThis skill should be used when creating a Claude Code slash command. Use when users ask to "create a command", "make a slash command", "add a command", or want to document a workflow as a reusable command. Essential for creating optimized, agent-executable slash commands with proper structure and best practices.
context-recoveryAutomatically recover working context after session compaction or when continuation is implied but context is missing. Works across Discord, Slack, Telegram, Signal, and other supported channels.
design-auditPremium UI/UX design auditor with Jobs/Ive philosophy. Use when reviewing, evaluating, or elevating existing UI — triggers on "audit my design", "review UI", "make it feel premium", "design review", "UX audit", "elevate the design", "Jobs/Ive style", or when asked to improve visual quality of an existing interface without changing functionality.
elegant-reportsGenerate beautifully designed PDF reports with a Nordic/Scandinavian aesthetic. Use when creating polished executive briefings, analysis reports, or presentation-style PDF outputs from markdown and HTML via Nutrient DWS.
gallery-scraperBulk download images from login-protected gallery websites using an attached browser session. Use when asked to scrape, download, or save images from authenticated gallery pages, extract full-size images from thumbnails, or batch download from multi-page galleries.
gongGong API for searching calls, transcripts, and conversation intelligence. Use when working with Gong call recordings, sales conversations, transcripts, meeting data, or conversation analytics. Supports listing calls, fetching transcripts, user management, and activity stats.