# Google Analytics

Traps to avoid when querying Google Analytics 4 through treg, cases where the GA4 Data...

- Repository: https://github.com/superdesigndev/treg (6950 stars)
- Category: Engineering
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add superdesigndev/treg --skill google-analytics -g -a claude-code -y`
Codex: `npx skills add superdesigndev/treg --skill google-analytics -g -a codex -y`
Cursor: `npx skills add superdesigndev/treg --skill google-analytics -g -a cursor -y`
Gemini CLI: `npx skills add superdesigndev/treg --skill google-analytics -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add superdesigndev/treg`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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:

```bash
# 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:

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