首页龙虾技能列表 › Google-analytics-GA4

Google-analytics-GA4

v1.0.0

Query Google Analytics GA4 properties for realtime and historical user metrics, dimensions, and metadata using the official Data API.

1· 122·0 当前·0 累计
by @whosc (whao)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/20
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
The skill's code, instructions, and environment needs are consistent with its stated purpose of querying GA4 via the official Data API; nothing in the package appears to request unrelated credentials or reach out to unknown endpoints.
评估建议
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 diff...
详细分析 ▾
用途与能力
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.
指令范围
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.
安装机制
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).
凭证需求
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.
持久化与权限
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.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/20

Call the Google Analytics API from the command line to read GA4 data (not Universal Analytics).

● 无害

安装命令 点击复制

官方npx clawhub@latest install google-analytics-ga4
镜像加速npx clawhub@latest install google-analytics-ga4 --registry https://cn.clawhub-mirror.com

技能文档

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

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

2. Create a JSON key

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

3. Grant GA4 access

  • Open Google Analytics.
  • Select the property.
  • Admin (gear) → Property access management.
  • Add users → enter the service account email (…@….iam.gserviceaccount.com).
  • 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

ArgumentDescriptionDefault
--property-idNumeric GA4 property IDRequired (except list-properties)
--credentialsService account JSON pathga-credentials.json

Realtime

ArgumentDescriptionDefault
--metricsComma-separated metricsactiveUsers
--dimensionsComma-separated dimensions(none)
--minute-rangeMinutes ago window, e.g. 0-300-30

Historical

ArgumentDescriptionDefault
--start-dateStart (YYYY-MM-DD or relative)Required
--end-dateEndRequired
--metricsComma-separated metricsactiveUsers
--dimensionsComma-separated dimensions(none)
--limitMax rows10000
--offsetPaging offset0

Common metrics

NameMeaning
activeUsersActive users
sessionsSessions
eventCountEvent count
engagementRateEngagement rate
averageSessionDurationAvg session duration (seconds)
screenPageViewsPage / screen views
conversionsConversions
totalRevenueRevenue

Common dimensions

NameMeaning
countryCountry
cityCity
deviceCategorydesktop / mobile / tablet
eventNameEvent name
pagePathPage path
sourceTraffic source
mediumMedium
campaignCampaign
dateDate

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

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务