跳到正文
Skillpedia
分析与电子表格7.0k · #13698

google-analytics

它能做什么

这项技能列出 GA4 报告中的一些陷阱,这些陷阱会在没有错误提示的情况下给出错误答案。它适合报告网站流量、转化或收入的分析师和智能体。

适用场景

  • ✓当你在 GA4 中回答有关网站流量、页面浏览量或渠道的问题时。
  • ✓当你在报告转化或收入,而某个数字显示为零的时候。
  • ✓当你比较的日期范围包含当天时。

技能链接

https://github.com/superdesigndev/treg/blob/main/.agents/skills/google-analytics/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/superdesigndev/treg/blob/main/.agents/skills/google-analytics/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“过去 28 天有多少访客访问了我的网站,我们获得了多少收入?”

每周 5 个新技能,1 分钟读完。

工作原理

除非你另有要求,智能体会使用昨天作为日期,而不是今天;在报告零值之前,它会检查转化是否已被跟踪。它会说明所应用的任何不完整当日数据的注意事项。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

GA4 via treg — what will silently mislead you

You already know the GA4 Data API. This file is only the things that return a plausible wrong answer with no error. Everything here was verified live on 2026-07-22, and each trap was confirmed by watching three independent agents walk into it.

Property id: treg connections ls → the google-analytics row's resource_ref.

1. endDate:"today" silently includes a partial day

3 of 3 agents did this. It inflates every number and you will not notice.

28daysAgo → today      /top-page = 45,120   ← includes a partial day
28daysAgo → yesterday  /top-page = 44,300

Use yesterday unless the user explicitly asks about today. If you must use today, say the last day is partial.

2. Zero does not mean zero — check whether it's even tracked

3 of 3 agents reported "$0 revenue and 0 conversions" for a business with real revenue. Two rated it high confidence; one argued the zero was trustworthy because eventCount was large.

keyEvents, conversions, and totalRevenue all return 0 when nothing is instrumented, which is indistinguishable from genuinely zero. Before reporting any zero:

# does this property have ANY key events configured?
--data '{"dateRanges":[...],"metrics":[{"name":"keyEvents"}]}'

Don't request keyEvents and conversions in the same call — they're aliases and GA4 rejects it with 400 Found duplicate metrics: conversions. Pick one.

If keyEvents is 0 across a long window on a site with traffic, the correct answer is "conversions are not instrumented in GA4; this question can't be answered from this source" — never "revenue is $0". Revenue almost certainly lives in Stripe/PostHog instead.

3. A zero-row response has NO rows key at all

Not rows: [] — the key is absent, and so is rowCount. The shape varies by query:

Query Top-level keys returned
grouped by a dimension ['dimensionHeaders','metricHeaders','metadata','kind']
metrics only (e.g. keyEvents) ['metadata','kind'] — headers gone too

A naive d['rows'] raises KeyError, which reads as a malformed request. All three unskilled agents were confused by this. Use d.get('rows', []), treat empty as "no data", then apply trap #2.

3b. Don't list dateRange as a dimension

Comparing two periods is a standard ask, and the obvious move errors:

400: "Field dateRange is not a dimension. This field can be used in a Pivot or
      OrderBy like a dimension, but does not need to be listed in the Dimensions."

Pass 2+ entries in dateRanges and the API auto-appends the range as an extra dimension value. Give the ranges names to label them in the output.

4. Dimension sums do NOT equal totals — they overcount

Measured against a dimensionless true total (illustrative, ratios are the point):

Grouped by Sum vs true total
sessionDefaultChannelGroup ~104%
country ~104%
pagePath ~189%

Sessions span multiple pages, so per-page sums double-count badly. Never sum a dimension to report a total — run a separate dimensionless query.

5. limit defaults to 10,000 and truncates silently

An unlimited pagePath query returned exactly 10,000 rows with "rowCount": 42613 — 32,613 rows dropped, no warning. rowCount is the truth; len(rows) is not. Compare them before saying "all" or "every".

6. The Admin API is a different host and is unreachable via /call/

The tool is bound to analyticsdata.googleapis.com. Anything on analyticsadmin.googleapis.com — accountSummaries, property metadata — returns a Google HTML 404, not JSON. Two of three agents burned several attempts here, including trying to pass an absolute URL (which gets concatenated into garbage).

To list properties, use treg, not the proxy:

treg connections resources <connection-id>   # hits the Admin API server-side

Everything else

Standard GA4 Data API. runReport, runRealtimeReport, batchRunReports, runPivotReport, checkCompatibility, /metadata all verified working through /call/. Two minor notes: metric values are strings (cast before arithmetic), and metadata.timeZone governs what "today" means (a property reports in its own timezone, e.g. Australia/Sydney).

⚠️ Reported but not observed here: high-cardinality dimensions can collapse into an (other) row.

常见问题

为什么不把今天作为结束日期?

该技能说明,今天包含一个不完整的日期,这会使总数虚高。

如果收入显示为零怎么办?

该技能要求检查是否已配置关键事件,因为零可能意味着什么都没有被跟踪。

我可以在同一次请求中请求两个相互冲突的指标吗?

该技能警告,有些指标是别名,不能在同一次调用中请求。

详情

作者的原始描述

Traps to avoid when querying Google Analytics 4 through treg — cases where the GA4 Data API returns a confident wrong answer instead of an error. Use whenever answering questions about site traffic, visitors, pageviews, channels, conversions, or revenue from GA4.

repo: superdesigndev/treg

热度

GitHub 星标
7.0k
排名
#13698
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能