← Guides·BigQuery Data Agents

BigQuery Data Agents

Check a BigQuery agent’s answer: six errors on GA4 data

How to ask a BigQuery data agent better questions, read its answer critically, and spot the six errors agents make most often on GA4 data.

David PombarSwiss army knife at Trackingplan
7 min read · 1434 words

A data agent always answers. That is its strength and its risk. It will return a confident number for a question it misread, from a query that counted the wrong thing, with a chart that makes it look settled. The SQL is right there, but nobody reads SQL they didn’t ask for.

This guide is about the habit that makes an agent safe to use: asking questions it can’t misread, and reading each answer as a claim to verify. It ends with the six errors agents make most often on GA4 data, so you know where to look first.

A magnifying glass held over a page of newspaper text, enlarging one line
The number is the claim. The query is the evidence. Image: Ze’ev Barkan, Wikimedia Commons, CC BY 2.0

Goal of this guide: ask questions that leave the agent few choices, and catch a wrong answer before anyone acts on it. You need: the agent from guide 5 and the checklist from guide 2.

Ask questions that leave few choices

Every word you leave out is a decision the agent makes for you. “How are sales doing?” leaves it to choose the metric, the period, the grain, and what to compare with. It will choose something reasonable, and possibly not what you meant.

Diagram of a well-formed question split into its four parts: the metric, revenue from purchases; the period, January 2021; the grain, by session medium; the comparison, versus December 2020.
Four parts, four fewer guesses. The agent fills in whatever you leave out.

Name four things:

Follow-up questions keep the context of the conversation, so you can start broad and narrow down. When the agent asks you a clarifying question, that is a good sign; answer it rather than rephrasing from scratch.

Read the answer in four layers

An answer has more in it than the number.

  1. The text. Does it restate your question the way you meant it? If it says “sessions by source” and you asked by medium, stop here.
  2. The chart. Does the axis match the grain you asked for? Is a period missing?
  3. Show thinking. The agent’s reasoning, step by step. Look for the moment it chose a table or a definition.
  4. How was this calculated? The SQL and its raw result. This is the evidence; the rest is presentation.

Then run the five-point checklist on the SQL: the table, the dates, the filters, what is counted, and duplication. It takes a minute once you have done it ten times.

Compare with a number you trust

The fastest check is a known number. For GA4 data, that is usually the GA4 interface. Expect a gap, and know what size is normal: as guide 3 explained, the interface approximates users and sessions, applies thresholds, and adds modeled data, and the export does none of that.

A gap of a few percent on users or sessions is usually explained by those differences. A gap of 30% on revenue is not; something is wrong in the query or in the data. The point is not to match the interface. It is to know why you don’t.

The six errors agents make on GA4 data

Grid of six common data agent errors on GA4 data, each with how to spot it in the SQL: first source as channel, revenue summed after unnesting items, sessions summed by day, UTC versus property time zone, events counted as users, and missing values hidden in one group.
Six errors, six places to look in the SQL. Most wrong answers are one of these.

1. The user’s first source as the session’s channel

Spot it: the query uses traffic_source.source or traffic_source.medium for a question about channels or campaigns. Those columns describe how the user was first acquired. Fix it: a field description and an instruction that point to the session’s source. If you built agent_layer, the agent never sees the raw column.

2. Revenue summed after unnesting items

Spot it: UNNEST(items) in the FROM clause and SUM(ecommerce.purchase_revenue) in the SELECT. Each transaction’s revenue is added once per product. Fix it: separate tables for purchases and purchase items, as in guide 4.

3. Sessions added up day by day

Spot it: a count of sessions grouped by day, then summed for a total. A session that crosses midnight is counted twice. Fix it: count distinct session keys over the whole period, and tell the agent to.

4. Two time zones in one query

Spot it: a filter on event_timestamp and a grouping on event_date, or the other way around. event_timestamp is UTC, event_date is the property’s time zone, and events near midnight change day. Fix it: one date column in the layer, described with its time zone.

5. Events counted as users

Spot it: COUNT(*) for a question about users or customers. Fix it: a glossary term for “users” that says COUNT(DISTINCT user_pseudo_id), and a verified query that shows it.

6. Missing values hidden in one group

Spot it: a large row labeled NULL, empty, or (not set) in a breakdown, presented as if it were a category, or a filter such as != 'organic' that silently drops the rows where the value is missing. Fix it: tell the agent to report missing values as their own line, with their share, and to say when they are large.

How a production agent does it. A language model handed a symptom will always find a plausible story for it. Trackingplan’s agent has a rule against that: it names a cause only when two independent pieces of evidence agree, such as a container change detected just before the problem started plus traffic or a live check confirming how it broke. Anything less is presented as a hypothesis and labeled as one (how it works). You can apply the same rule by hand: before you accept an agent’s explanation of why a number moved, find a second, independent piece of evidence for it.

When the answer is wrong, fix the agent

Rephrasing the question until the number looks right teaches you nothing and leaves the next person to hit the same error. Each wrong answer points to something missing in the agent:

What went wrongWhat to change
It used the wrong table or columnThe table or field description
It misread a business termA glossary entry
It chose the wrong default, such as the periodThe instructions
It wrote the wrong SQL for a common questionA verified query
It needed a table that isn’t thereA new table in your layer

The next guide covers the last three tools in detail.

Exercise

Ask your agent three questions phrased loosely (“how did we do in January?”, “what’s our best channel?”, “how many customers do we have?”) and the same three phrased with metric, period, grain, and comparison. Compare the SQL of each pair. Write down every choice the agent made on its own in the loose versions.

How to know you got it right

Resources

FAQ

How do I know if a BigQuery data agent’s answer is right? Open the SQL behind it with How was this calculated? and check the table, the dates, the filters, what is counted, and whether a join or UNNEST duplicates rows. Then compare the number with one you already trust, such as the GA4 interface, and expect small, explainable gaps rather than none.

What mistakes do data agents make on GA4 data? The common six: using the user’s first source as the session’s channel, summing revenue after unnesting items, adding up sessions day by day, mixing UTC timestamps with the property’s dates, counting events when the question was about users, and hiding missing values in a large unlabeled group.

How should I phrase questions to a data agent? Say the metric, the period, the grain, and the comparison: “revenue from purchases, by session medium, for January 2021, compared with December 2020.” The fewer choices the agent has to make, the fewer it gets wrong.

Next: Instructions, glossary, and verified queries.

David PombarSwiss army knife at Trackingplan

Read more from David, a Senior Product Strategist with 18+ years in digital product development and an atypical error detection knack.

Trackingplan

See everything. Miss nothing.

Your implementations audited around the clock with real-time, real-user data. Real-time alerts about errors or changes in your data, campaigns, pixels, privacy and consent. Let AI flag issues before they cost you.