← Back to Skills Marketplace
whosc

Google-analytics-GA4

by whao · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
176
Downloads
1
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install google-analytics-ga4
Description
Query Google Analytics GA4 properties for realtime and historical user metrics, dimensions, and metadata using the official Data API.
README (SKILL.md)

Google Analytics skill

Query GA4 properties using the Google Analytics Data API v1.

Capabilities

  • Realtime metrics — e.g. active users in the last N minutes
  • Historical reports — custom date ranges, metrics, dimensions, paging
  • Metadata — discover valid dimension and metric API names
  • Property list hint — Data API alone cannot enumerate properties; doc explains where to find the numeric ID

Setup

1. Create a service account

  1. Open Google Cloud Console.
  2. Create or select a project.
  3. Enable Google Analytics Data API.
  4. Create a service account: IAM & AdminService AccountsCreate service account.
    • Optional GCP role: BigQuery Job User (only if you also use BigQuery).
  5. Finish the wizard.

2. Create a JSON key

  1. Open the service account → Keys.
  2. Add keyCreate new keyJSON.
  3. Download the file and save it as ga-credentials.json (or any path you pass via --credentials / GOOGLE_APPLICATION_CREDENTIALS).

3. Grant GA4 access

  1. Open Google Analytics.
  2. Select the property.
  3. Admin (gear) → Property access management.
  4. Add users → enter the service account email (…@….iam.gserviceaccount.com).
  5. Role: at least Viewer.

4. Credentials location

Either:

  • A. Place ga-credentials.json in this skill directory, or
  • B. Set GOOGLE_APPLICATION_CREDENTIALS to the absolute path of the JSON key.

Never commit real keys. .gitignore excludes ga-credentials.json and config.json.

Examples

Property list guidance

python ga_query.py --action list-properties

Realtime (active users)

python ga_query.py --action realtime \
  --property-id YOUR-GA4-PROPERTY-ID

Historical

python ga_query.py --action historical \
  --property-id YOUR-GA4-PROPERTY-ID \
  --start-date 7daysAgo \
  --end-date yesterday \
  --metrics activeUsers,sessions,eventCount \
  --dimensions country,deviceCategory

Metadata

python ga_query.py --action metadata \
  --property-id YOUR-GA4-PROPERTY-ID

Arguments

Common

Argument Description Default
--property-id Numeric GA4 property ID Required (except list-properties)
--credentials Service account JSON path ga-credentials.json

Realtime

Argument Description Default
--metrics Comma-separated metrics activeUsers
--dimensions Comma-separated dimensions (none)
--minute-range Minutes ago window, e.g. 0-30 0-30

Historical

Argument Description Default
--start-date Start (YYYY-MM-DD or relative) Required
--end-date End Required
--metrics Comma-separated metrics activeUsers
--dimensions Comma-separated dimensions (none)
--limit Max rows 10000
--offset Paging offset 0

Common metrics

Name Meaning
activeUsers Active users
sessions Sessions
eventCount Event count
engagementRate Engagement rate
averageSessionDuration Avg session duration (seconds)
screenPageViews Page / screen views
conversions Conversions
totalRevenue Revenue

Common dimensions

Name Meaning
country Country
city City
deviceCategory desktop / mobile / tablet
eventName Event name
pagePath Page path
source Traffic source
medium Medium
campaign Campaign
date Date

Date expressions

  • Absolute: 2024-01-15
  • Relative: today, yesterday, 7daysAgo, 30daysAgo

Output

Default: Markdown tables. Use --output json for machine-readable output.

Dependencies

pip install google-analytics-data

Optional (traffic source report + DingTalk): pip install requests and set DINGTALK_WEBHOOK / DINGTALK_SECRET.

References

Usage Guidance
This appears to be a legitimate GA4 reporting skill. Before installing: (1) do not commit real service-account JSON keys to repos; use a Viewer-limited service account; (2) check there is no unexpected ga-credentials.json with secrets in the skill directory (the repo includes an empty ga-credentials.json placeholder); (3) be aware some scripts set GOOGLE_APPLICATION_CREDENTIALS to the local ga-credentials.json which may override your global setting — remove or edit that line if you prefer a different path; (4) only set DINGTALK_WEBHOOK / DINGTALK_SECRET if you want outgoing notifications; and (5) review and run test_connection.py first to confirm permissions and quotas before doing large exports.
Capability Analysis
Type: OpenClaw Skill Name: google-analytics-ga4 Version: 1.0.0 The bundle provides a legitimate set of tools for querying Google Analytics (GA4) data via the official Google Analytics Data API v1. It includes a main CLI tool (ga_query.py), an OpenClaw wrapper (openclaw_ga.py), and a reporting script (traffic_source_report.py) that can optionally send reports to a DingTalk webhook. All network activities and credential handling (via GOOGLE_APPLICATION_CREDENTIALS) are aligned with the stated purpose of the skill. No evidence of malicious intent, prompt injection, or unauthorized data exfiltration was found.
Capability Assessment
Purpose & Capability
Name/description (GA4 reporting) matches the included files (CLI, helper, tests, optional report). Required dependencies (google-analytics-data, requests optional) are appropriate for the functionality.
Instruction Scope
SKILL.md and code confine actions to creating/using a Google service account JSON key, calling the GA4 Data API, and optionally sending notifications (DingTalk) if the user configures webhook env vars. One small surprise: several scripts unconditionally set GOOGLE_APPLICATION_CREDENTIALS to ./ga-credentials.json which can override an existing environment variable — the docs mention both options, but the script behavior may be unexpected to some users.
Install Mechanism
No automatic install/downloads or remote installers; dependencies are standard Python packages listed in requirements.txt. The package is shipped as source files (no opaque external payloads).
Credentials
The skill does not request unrelated secrets. It expects a Google service account JSON (GOOGLE_APPLICATION_CREDENTIALS or ga-credentials.json) and may use GA4_PROPERTY_ID or a config.json for property selection. Optional DingTalk webhook env vars are documented — these are reasonable but are unrelated to GA4 data access and should only be set if you intend to use notifications.
Persistence & Privilege
Skill is not force-included (always:false) and does not modify other skills or global agent configuration. It runs on-demand and has no elevated platform privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install google-analytics-ga4
  3. After installation, invoke the skill by name or use /google-analytics-ga4
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Call the Google Analytics API from the command line to read GA4 data (not Universal Analytics).
Metadata
Slug google-analytics-ga4
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Google-analytics-GA4?

Query Google Analytics GA4 properties for realtime and historical user metrics, dimensions, and metadata using the official Data API. It is an AI Agent Skill for Claude Code / OpenClaw, with 176 downloads so far.

How do I install Google-analytics-GA4?

Run "/install google-analytics-ga4" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Google-analytics-GA4 free?

Yes, Google-analytics-GA4 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Google-analytics-GA4 support?

Google-analytics-GA4 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Google-analytics-GA4?

It is built and maintained by whao (@whosc); the current version is v1.0.0.

💬 Comments