google-analytics
Fungsinya
Skill ini mencantumkan jebakan pelaporan GA4 yang memberi jawaban salah tanpa disertai error. Skill ini ditujukan untuk analis dan agent yang melaporkan lalu lintas situs, konversi, atau pendapatan.
Kapan dipakai
- βSaat Anda menjawab pertanyaan tentang lalu lintas situs, tampilan halaman, atau saluran di GA4.
- βSaat Anda melaporkan konversi atau pendapatan dan sebuah angka menunjukkan nol.
- βSaat Anda membandingkan rentang tanggal yang mencakup hari ini.
Link skill
https://github.com/superdesigndev/treg/blob/main/.agents/skills/google-analytics/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBerapa banyak pengunjung yang datang ke situs saya dalam 28 hari terakhir, dan berapa pendapatan yang kita hasilkan?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memakai tanggal kemarin sebagai tanggal akhir, kecuali Anda meminta lain, dan memeriksa apakah konversi sudah dilacak sebelum melaporkan nilai nol. Agent menjelaskan peringatan hari yang belum lengkap jika berlaku.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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.
- API schema: https://developers.google.com/analytics/
Pertanyaan umum
Mengapa tidak memakai hari ini sebagai tanggal akhir?
Skill ini menyebutkan bahwa hari ini mencakup hari yang belum lengkap, sehingga total menjadi terlalu tinggi.
Bagaimana jika pendapatan menunjukkan nol?
Skill ini menyebutkan untuk memeriksa apakah event kunci sudah diatur, karena nol bisa berarti tidak ada yang dilacak.
Bisakah saya meminta dua metrik yang saling bertentangan sekaligus?
Skill ini memperingatkan bahwa beberapa metrik adalah alias dan tidak dapat diminta dalam satu panggilan yang sama.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 7.0k
- Peringkat
- #13698
- Lisensi
- β
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
code-quality
7.0kMengajari agent Anda standar kode yang jelas: menegakkan aturan dengan alat, menjaga komentar tetap jarang, membuat tes yang bisa gagal, dan menjaga dokumentasi tetap singkat.
google-ads
7.0kMembantu agent Anda menjalankan laporan dan perubahan Google Ads dengan aman, menghindari kesalahan versi API dan anggaran yang membuang uang.
google-search-console
7.0kMembantu agent Anda melaporkan klik, impresi, dan peringkat pencarian organik dari Search Console tanpa salah mengira hari terbaru yang belum lengkap sebagai penurunan.
portrait-clone
7.0kMembantu agent Anda mengubah foto referensi seseorang menjadi satu prompt gambar JSON yang rinci, dengan setiap pilihan visual dikunci agar hasilnya konsisten.
Skill serupa
gitcrawl
394kMemungkinkan agent Anda mencari arsip issue dan pull request GitHub yang tersimpan, mengelompokkan yang duplikat, dan memeriksa status terkininya di GitHub.
slacrawl
394kMemungkinkan agent Anda mencari dan menghitung pesan di arsip Slack lokal, memeriksa seberapa baru arsip itu, dan menyegarkannya bila diperlukan.
goplaces
394kMembantu agent Anda mencari tempat, mendapatkan detail dan ulasannya, serta menentukan nama tempat memakai Google Places, dengan keluaran JSON untuk skrip.