Aller au contenu
Skillpedia
Analyse et tableurs7.0k · #13698

google-analytics

Ce qu’il fait

Ce skill liste les pièges de reporting de GA4 qui donnent de mauvaises réponses sans erreur. Il s'adresse aux analystes et aux agents qui rendent compte du trafic, des conversions ou des revenus d'un site web.

Quand l’utiliser

  • ✓Quand vous répondez à des questions sur le trafic, les pages vues ou les canaux dans GA4.
  • ✓Quand vous rendez compte de conversions ou de revenus et qu'un chiffre affiche zéro.
  • ✓Quand vous comparez des périodes qui incluent le jour en cours.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/superdesigndev/treg/blob/main/.agents/skills/google-analytics/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Combien de visiteurs ont visité mon site au cours des 28 derniers jours, et quel chiffre d'affaires avons-nous réalisé ?”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent utilise la date d'hier au lieu d'aujourd'hui, sauf indication contraire, et vérifie si les conversions sont suivies avant de signaler un zéro. Il explique toute réserve liée à un jour partiel.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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.

Questions fréquentes

Pourquoi ne pas prendre aujourd'hui comme date de fin ?

Le skill indique qu'aujourd'hui comprend un jour partiel, ce qui gonfle les totaux.

Que faire si les revenus affichent zéro ?

Le skill indique de vérifier si les événements clés sont configurés, car un zéro peut signifier que rien n'est suivi.

Puis-je demander deux indicateurs contradictoires ensemble ?

Le skill avertit que certains indicateurs sont des alias et ne peuvent pas être demandés dans le même appel.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
7.0k
Position au classement
#13698
Licence
—
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires