← 返回 Skills 市场
nanaco666

GA4 Connector

作者 nanaco · GitHub ↗ · v0.1.1 · MIT-0
cross-platform ✓ 安全检测通过
234
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install ga4-connector
功能描述
Query Google Analytics 4 (GA4) data through the Google Analytics Data API for trends, countries, sources, pages, and conversion analysis. Use when a user wan...
使用说明 (SKILL.md)

GA4 Data API

Use this skill to set up and query GA4 through OAuth user authorization.

Default approach

Prefer OAuth user authorization first.

Use scripts/install_ga4_openclaw.sh + scripts/ga4_query.py for the normal path.

Only suggest service accounts later, when there is a clear need for headless/server-side access.

Hard rules

  1. Check account + permission before setup

    • Ask which Google account can actually log into GA and has property/account access.
    • Do not start with service-account setup by default for enterprise/internal data.
  2. Be honest about blockers

    • If the user cannot add users, say it is a permission blocker.
    • If the OAuth app is still in Testing, say the account must be added to test users.
    • If the user can see the property but lacks admin controls, say it is an access-level issue instead of pretending the button is hidden.

Setup flow

Step 1 — Verify access model

Ask/confirm:

  • Which Google account has GA access?
  • Can the user log into that account?
  • What is the GA4 Property ID?
  • Is Google Analytics Data API already enabled?
  • Is there already a Desktop OAuth client JSON?

Step 2 — Install and wire credentials

Run:

bash ~/.openclaw/workspace/skills/ga4-data-api/scripts/install_ga4_openclaw.sh \x3CGA4_PROPERTY_ID> \x3CPATH_TO_CLIENT_SECRET_JSON>

This installs Python deps, copies the OAuth client JSON into ~/.config/openclaw/ga4-client.json, and writes GA4_PROPERTY_ID into shell config.

Step 3 — First authorization

Run:

python3 ~/.openclaw/workspace/skills/ga4-data-api/scripts/ga4_query.py \
  --metrics activeUsers,sessions \
  --dimensions date \
  --start 7daysAgo \
  --end today \
  --pretty

The browser will open. The user must choose the same Google account that actually has GA access.

Successful authorization creates:

  • ~/.config/openclaw/ga4-token.json

Step 4 — Query examples

Recent trend:

python3 ~/.openclaw/workspace/skills/ga4-data-api/scripts/ga4_query.py \
  --metrics activeUsers,sessions \
  --dimensions date \
  --start 7daysAgo \
  --end yesterday \
  --pretty

Country split:

python3 ~/.openclaw/workspace/skills/ga4-data-api/scripts/ga4_query.py \
  --metrics activeUsers \
  --dimensions country \
  --start 7daysAgo \
  --end yesterday \
  --limit 50 \
  --pretty

Source split:

python3 ~/.openclaw/workspace/skills/ga4-data-api/scripts/ga4_query.py \
  --metrics sessions \
  --dimensions sessionSourceMedium \
  --start 7daysAgo \
  --end yesterday \
  --limit 50 \
  --pretty

Analysis guidance

For trend questions:

  • Prefer full days (end=yesterday) unless the user explicitly wants intraday.
  • Call out whether a same-day drop is just partial-day data.

For conversion questions:

  • Separate traffic events from true conversion events.
  • If key events look too broad, recommend narrowing the event set before drawing product conclusions.

References

  • Read references/setup.md when the user needs the shareable setup process.
  • Use scripts/ga4_query.py instead of hand-writing fresh GA SDK samples each time.
安全使用建议
This skill appears to do what it says (connect to GA4 via the Google Analytics Data API). Before installing, review and consider: 1) The installer will copy your Desktop OAuth client JSON into ~/.config/openclaw and create an OAuth token at ~/.config/openclaw/ga4-token.json — both grant access to GA data and should be kept private. 2) The installer will add an export GA4_PROPERTY_ID line to your shell rc (~/.bashrc or ~/.zshrc); back up that file first and inspect the change if you don't want environment modifications. 3) The script runs `python3 -m pip install --user google-analytics-data google-auth-oauthlib google-auth-httplib2` — this installs Python packages into your user environment and requires network access; inspect or run these commands manually if you prefer. 4) The OAuth flow opens a browser; ensure you authorize the correct Google account that has GA4 property access. 5) Minor path inconsistency in some echo messages (the README/install prompts reference slightly different paths) — double-check the actual script locations before running commands. If you or your organization handle enterprise GA data, follow the hard rules in SKILL.md (verify account/permissions first and prefer OAuth user auth over service accounts).
功能分析
Type: OpenClaw Skill Name: ga4-connector Version: 0.1.1 The ga4-connector skill is a standard integration for querying Google Analytics 4 data using official Google libraries. It includes a setup script (install_ga4_openclaw.sh) that manages local configuration and environment variables in shell RC files, and a query script (ga4_query.py) that implements a standard OAuth2 flow to retrieve metrics. No evidence of data exfiltration, malicious execution, or prompt injection was found.
能力评估
Purpose & Capability
Name/description claim GA4 Data API access; included scripts implement OAuth InstalledAppFlow, call the google.analytics.data client, and provide query examples. Required behaviors (client secret, token cache, property ID) are all appropriate for the stated purpose.
Instruction Scope
SKILL.md and scripts are focused on GA4 setup and queries. They instruct installing Python packages, copying the OAuth client JSON to ~/.config/openclaw, running an OAuth browser flow, and storing the token at ~/.config/openclaw/ga4-token.json. Those actions are within the expected scope but are persistent filesystem and shell-config changes (see persistence).
Install Mechanism
No external arbitrary downloads; install script uses `python3 -m pip install --user` for well-known google-auth and analytics packages. No archives or remote executables are fetched from untrusted URLs. This is a typical, low-risk install path for a Python-based connector.
Credentials
The repository metadata lists no required env vars, but the code accepts GA4_PROPERTY_ID via env/argument and the installer writes `export GA4_PROPERTY_ID=...` into the user's shell rc. The skill requires and persists the client secret JSON and OAuth token locally — these are sensitive and should be treated like credentials. This request is proportional to its function, but users must protect those files.
Persistence & Privilege
The skill is not always-enabled and does not request elevated system privileges. It does modify the user's shell rc to export GA4_PROPERTY_ID and writes files to ~/.config/openclaw (client secret and token) and installs Python packages to the user site. Those are expected for this connector but are persistent changes the user should review before running.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ga4-connector
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ga4-connector 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.1
- Renamed the skill from "ga4-data-api" to "ga4-connector". - No changes to functionality, documentation, or setup instructions.
元数据
Slug ga4-connector
版本 0.1.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

GA4 Connector 是什么?

Query Google Analytics 4 (GA4) data through the Google Analytics Data API for trends, countries, sources, pages, and conversion analysis. Use when a user wan... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 234 次。

如何安装 GA4 Connector?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ga4-connector」即可一键安装,无需额外配置。

GA4 Connector 是免费的吗?

是的,GA4 Connector 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

GA4 Connector 支持哪些平台?

GA4 Connector 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 GA4 Connector?

由 nanaco(@nanaco666)开发并维护,当前版本 v0.1.1。

💬 留言讨论