---
title: "GA4 anomaly detection and forecasting: signal to explanation"
description: "GA4 anomaly detection flags a day but never says why. On the public sample, a 28-day band finds four odd days in 92: the SQL, the forecast, the why."
canonical: https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model
date: 2026-11-26T11:30:00+01:00
author: "Boris Parov"
lang: en
---

# Anomaly detection and forecasting on GA4: from signal to explanation

GA4 anomaly detection compares each day's KPI with the range its own history predicts. The automatic alerts of Google Analytics 4 (GA4) do this on 90 days of data. They stop at the signal. On the public BigQuery sample, a 28-day moving band flags four days out of 92. This guide finds them, forecasts the month, and explains the change.

**Key takeaways**

- Per Google's documentation, GA4's automatic alerts train on 90 days of daily data and flag a signal. They never return the market, channel, or device behind it.
- On the public sample, a 28-day band at two standard deviations flags four of 92 days, three of them between 2020-12-07 and 2020-12-09.
- A naive run rate on 2021-01-15 missed the month-end landing by +1.9%; a model forecast missed it by +4.7% but gave an interval that contained it.
- Between December 2020 and January 2021, sessions fell by about 11% on desktop, mobile, and tablet alike: the device dimension explains nothing.
- The public sample holds no session whose source or medium names an AI assistant: that channel did not exist in 2020-2021.

| Question you are asked                              | Where the answer is                                                                                                                                              |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Did GA4 already warn us, and why did we miss it?    | the limits of GA4's automatic anomaly alerts                                                                                                                     |
| Which day was abnormal, on which market and device? | [anomaly detection in BigQuery with ARIMA_PLUS](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/bigquery-ml-anomaly-detection-arima-plus)  |
| Where will the month land?                          | forecasting the month-end landing with a confidence interval                                                                                                     |
| Why did the KPI move?                               | decomposing a KPI change by market, channel, and device                                                                                                          |
| How much traffic do ChatGPT and Perplexity send us? | [measuring AI assistant traffic in GA4](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/measure-chatgpt-perplexity-traffic-ga4)            |
| Can an assistant answer on our Power BI model?      | why a governed model comes before any assistant                                                                                                                  |
| How do we prepare the model for Copilot?            | [preparing a Power BI semantic model for Copilot](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/prepare-semantic-model-copilot-power-bi) |
| Who writes the Monday brief?                        | writing a weekly brief from the numbers                                                                                                                          |

## What GA4's automatic anomaly alerts catch, and what they miss

GA4's automatic alerts catch a daily KPI that leaves its predicted range, and they miss everything about the cause. Google documents the method. A Bayesian state-space time series model is fitted on the history and predicts the latest point. The actual value is flagged when it falls outside the credible interval. The training window is fixed: two weeks for hourly data, 90 days for daily data, 32 weeks for weekly data. A second mechanism runs once a week on segments. It applies principal components analysis to metrics normalized by segment size. A segment is surfaced only if it holds at least 0.05% of the property's users.

Three limits follow from that design. First, the alert covers one metric at a time, on the whole property or on a segment GA4 chose. It does not cover the market and device combination you manage. Second, the predicted range is not exported. You see a card, not the band, so you cannot audit the threshold or replay it on last quarter. Third, the alert says nothing about the why. A drop in sessions on a Tuesday arrives as a sentence. The market, the channel, or the tagging release behind it stays your job. The alert cards also sit inside the interface, where sampling, thresholds, and the "(other)" row already reshape the numbers.

The alerts remain useful as a first signal. The 90-day window is a reasonable default you can reuse in SQL. What they cannot be is the system of record for anomalies. Nothing they produce can be joined, filtered, or recomputed. GA4's automatic anomaly alerts: what they catch, what they miss goes through each limit, card by card, with the custom conditions you can set.

## How to detect a KPI anomaly in BigQuery with a moving band

A moving band flags a day that strays from the mean of the previous 28 days. The band's width is a multiple of their standard deviation, computed in BigQuery on the raw export. The method is deliberately simple. There is no model to train, one window function, and a result you can replay on any period. Two standard deviations is the usual threshold. On a stable series it flags roughly one day in twenty, a noise level a reviewer can absorb.

An **anomaly** is a daily value of a KPI that falls outside the range its own history predicts, once trend and seasonality are accounted for; it is a statistical flag, not a diagnosis, and it says nothing by itself about the market, channel, or device that caused it. An **expected range** is the band around the predicted value, bounded by a chosen number of standard deviations or by a prediction interval, inside which a day is considered normal and outside which it is flagged.

```sql
WITH daily AS (
  SELECT
    PARSE_DATE('%Y%m%d', event_date) AS day,
    COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
  GROUP BY day
),
banded AS (
  SELECT
    day,
    sessions,
    AVG(sessions) OVER w AS mean_28d,
    STDDEV_SAMP(sessions) OVER w AS sd_28d
  FROM daily
  WINDOW w AS (ORDER BY day ROWS BETWEEN 28 PRECEDING AND 1 PRECEDING)
)
SELECT
  day,
  FORMAT_DATE('%a', day) AS weekday,
  sessions,
  ROUND(mean_28d) AS expected,
  ROUND(mean_28d - 2 * sd_28d) AS lower_band,
  ROUND(mean_28d + 2 * sd_28d) AS upper_band,
  ROUND((sessions - mean_28d) / sd_28d, 1) AS z_score
FROM banded
WHERE ABS(sessions - mean_28d) > 2 * sd_28d
ORDER BY day
```

| Day        | Weekday | Sessions | Expected | Lower band | Upper band | z-score |
| ---------- | ------- | -------- | -------- | ---------- | ---------- | ------- |
| 2020-11-03 | Tue     | 5,356    | 3,178    | 1,614      | 4,742      | 2.8     |
| 2020-12-07 | Mon     | 5,461    | 3,842    | 2,348      | 5,337      | 2.2     |
| 2020-12-08 | Tue     | 7,588    | 3,920    | 2,323      | 5,517      | 4.6     |
| 2020-12-09 | Wed     | 6,290    | 4,054    | 1,941      | 6,168      | 2.1     |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). Expected values and bands are rounded to the unit.

Four days out of 92 leave the band, all of them upward. Three sit together, from 2020-12-07 to 2020-12-09. The peak is 7,588 sessions on the Tuesday, against an expected 3,920. That cluster is what a reviewer wants in one line. A promotion, a mailing, or a press mention in early December are the usual suspects. The band also shows its weakness. The three days inflate the next 28-day mean, so a quieter Christmas week never gets flagged downward.

## Why weekly seasonality decides what counts as an anomaly

Weekly seasonality decides what counts as an anomaly. The real signal is a Sunday that looks like a Tuesday. On the public sample, Sunday runs 26% below the daily average and Tuesday 19% above it. A band that ignores the weekday treats every weekend as a dip and every Tuesday as a spike. It then buries the one Tuesday that matters.

```sql
WITH daily AS (
  SELECT
    PARSE_DATE('%Y%m%d', event_date) AS day,
    COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
  GROUP BY day
)
SELECT
  FORMAT_DATE('%A', day) AS weekday,
  COUNT(*) AS days,
  ROUND(AVG(sessions)) AS avg_sessions,
  ROUND(100 * AVG(sessions) / (SELECT AVG(sessions) FROM daily) - 100, 1) AS vs_overall_avg_pct
FROM daily
GROUP BY weekday, EXTRACT(DAYOFWEEK FROM day)
ORDER BY EXTRACT(DAYOFWEEK FROM day)
```

| Weekday   | Days | Average sessions | Versus overall average |
| --------- | ---- | ---------------- | ---------------------- |
| Sunday    | 14   | 2,900            | -26.1%                 |
| Monday    | 13   | 3,994            | +1.8%                  |
| Tuesday   | 13   | 4,681            | +19.3%                 |
| Wednesday | 13   | 4,633            | +18.1%                 |
| Thursday  | 13   | 4,300            | +9.6%                  |
| Friday    | 13   | 3,927            | +0.1%                  |
| Saturday  | 13   | 3,108            | -20.8%                 |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). Averages rounded to the unit.

The spread between the quietest and the busiest weekday is 45 points of the average. That is wider than the two-standard-deviation band on most weeks. It explains why the moving band flagged only extreme days. Two fixes exist. The cheap one compares each day with the same weekday over the previous four weeks. It removes the weekly pattern at the cost of a smaller sample. The robust one fits a model that learns the weekly and yearly components explicitly, which an ARIMA_PLUS model does. Both fixes also need a floor. On a market with 40 sessions a day, a two-sigma band is wider than the series itself. The right answer there is to aggregate to the week.

## GA4 anomaly detection with BigQuery ML ARIMA_PLUS, by market and device

BigQuery ML detects an anomaly with an ARIMA_PLUS model. The model learns trend, weekly seasonality, and step changes for each series. It then returns every point with its bounds and an anomaly probability. The difference with the moving band is not accuracy on one series. It is that one statement trains hundreds of series at once, one per market and device, with `TIME_SERIES_ID_COL`.

The statement below is written against the BigQuery ML documentation consulted on 2026-10-15. It is not executed here. `CREATE MODEL` writes a model object, and this guide only runs read-only queries on the public sample. The results table is therefore absent on purpose.

```sql
CREATE OR REPLACE MODEL `your_project.your_dataset.sessions_by_country_device`
OPTIONS (
  MODEL_TYPE = 'ARIMA_PLUS',
  TIME_SERIES_TIMESTAMP_COL = 'day',
  TIME_SERIES_DATA_COL = 'sessions',
  TIME_SERIES_ID_COL = ['country', 'device'],
  DATA_FREQUENCY = 'DAILY',
  DECOMPOSE_TIME_SERIES = TRUE,
  CLEAN_SPIKES_AND_DIPS = FALSE
) AS
SELECT
  PARSE_DATE('%Y%m%d', event_date) AS day,
  geo.country AS country,
  device.category AS device,
  COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
GROUP BY day, country, device;

SELECT country, device, day, sessions, lower_bound, upper_bound, anomaly_probability
FROM ML.DETECT_ANOMALIES(
  MODEL `your_project.your_dataset.sessions_by_country_device`,
  STRUCT(0.95 AS anomaly_prob_threshold))
WHERE is_anomaly
ORDER BY day DESC;
```

Three settings deserve a decision rather than the default. `CLEAN_SPIKES_AND_DIPS` is `TRUE` by default and smooths the exact points you want to catch. For detection it is set to `FALSE`. `HOLIDAY_REGION` is off by default and takes an array of regions, one per market. Google's reference applies it only to daily or weekly series longer than a year. On 92 days it would change nothing, so the statement leaves it out. Add it once the history covers a full year. The output of `ML.DETECT_ANOMALIES` keeps the column names chosen at training, here `day` and `sessions`. Its threshold of 0.95 is the default; raising it widens the bounds and flags fewer days. The model also stores its decomposition. That is what lets a reviewer see whether a flagged day was trend, seasonality, or residual. [Detecting a KPI anomaly in BigQuery with ARIMA_PLUS](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/bigquery-ml-anomaly-detection-arima-plus) writes the model for sessions and transactions by market and device. It then compares two read-only methods on the public sample.

## Which method for which KPI: band, model, or weekly aggregate

The right detection method depends on the series volume and on who reads the flag. The sophistication of the model matters less. A sponsor reading one line a day needs few flags and a plain expected value. An analyst checking 200 market and device series needs a probability and a stored decomposition. The table gives the rule used in the rest of this guide.

| Option                                  | When to choose it                                                              | What it costs                                                      |
| --------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
| 28-day moving band                      | One or a few headline KPIs, over 500 sessions a day, read by a sponsor         | Weekday effect not modeled; a spike inflates the next four weeks   |
| Same-weekday comparison                 | Series with a strong weekly pattern and little history                         | Four points per comparison; a holiday Monday looks like an anomaly |
| `ARIMA_PLUS` with `ML.DETECT_ANOMALIES` | Dozens to hundreds of series by market, channel, and device; a year of history | A model to retrain; holiday regions to maintain per market         |
| Weekly aggregate                        | Any series under about 100 sessions a day                                      | Detection delayed by up to a week                                  |
| Rate KPIs (conversion, bounce)          | Treat as a ratio with a floor on the denominator                               | A rate on 30 sessions moves by 3 points for one order              |

A rate KPI needs the same care twice, because its numerator and its denominator can each be anomalous. A conversion rate that jumps on a day when sessions dropped is a sessions story, not a conversion story. The band or the model runs on both counts. The rate is flagged only when the numerator moves without its denominator.

Two rules hold whatever the option. The flag is stored with its bounds, so that a reviewer can replay the threshold on last quarter. And the anomaly table is joined to the dimensions. The next step, the decomposition, then starts from the flagged day rather than from a screenshot.

### What to check first when a day is flagged

A flagged day is checked in a fixed order, cheapest cause first. First, the data: is the day's export table complete, with events in every hour? Second, the tagging: did a release change the `purchase` or `page_view` events that day? A KPI that falls to zero overnight points to a tag before a market. On the public sample, January 2021 ends on a day with zero transactions. Nothing in the export says why. Third, the calendar: a promotion, a mailing, a press mention, or a public holiday in one market. Only then does the decomposition start. That order saves a morning spent decomposing a drop the tag manager caused. Write the outcome next to the flag: data, tagging, calendar, or business. After a quarter, that column shows which checks to automate.

## Forecasting the month-end landing: run rate versus a model

A month-end landing is forecast by adding the sessions already counted to a projection of the remaining days. The quality of that projection is the whole question. The simplest projection is the run rate: sessions to date, divided by days elapsed, multiplied by days in the month. On January 2021 of the public sample, it is surprisingly good.

```sql
WITH daily AS (
  SELECT
    PARSE_DATE('%Y%m%d', event_date) AS day,
    COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
  GROUP BY day
),
cumul AS (
  SELECT
    day,
    EXTRACT(DAY FROM day) AS day_number,
    SUM(sessions) OVER (ORDER BY day) AS sessions_to_date
  FROM daily
)
SELECT
  day_number AS as_of_day,
  sessions_to_date,
  ROUND(sessions_to_date / day_number * 31) AS linear_landing,
  (SELECT MAX(sessions_to_date) FROM cumul) AS actual_landing,
  ROUND(100 * (sessions_to_date / day_number * 31 - (SELECT MAX(sessions_to_date) FROM cumul)) / (SELECT MAX(sessions_to_date) FROM cumul), 1) AS error_pct
FROM cumul
WHERE day_number IN (7, 15, 22, 31)
ORDER BY day_number
```

| As of January | Sessions to date | Run-rate landing | Actual landing | Error |
| ------------- | ---------------- | ---------------- | -------------- | ----- |
| Day 7         | 26,374           | 116,799          | 118,618        | -1.5% |
| Day 15        | 58,493           | 120,886          | 118,618        | +1.9% |
| Day 22        | 86,089           | 121,307          | 118,618        | +2.3% |
| Day 31        | 118,618          | 118,618          | 118,618        | 0.0%  |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). Sessions are counted per day and summed; a session crossing midnight counts on both days.

A **prediction interval** is the band around a forecast inside which the model expects the actual value to fall with a stated probability, 95% by default in BigQuery ML; its width, not the central value, is what tells a reader how much to trust the number. The run rate has no interval. A model does. `AI.FORECAST` runs on a query without training a model and returns the bounds. The statement below was executed on the series through 2021-01-15 with a 16-day horizon.

```sql
WITH forecast AS (
  SELECT forecast_timestamp, forecast_value, prediction_interval_lower_bound, prediction_interval_upper_bound
  FROM AI.FORECAST(
    (
      SELECT
        TIMESTAMP(PARSE_DATE('%Y%m%d', event_date)) AS day,
        COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
      FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
      WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210115'
      GROUP BY day
    ),
    data_col => 'sessions',
    timestamp_col => 'day',
    horizon => 16,
    confidence_level => 0.95)
)
SELECT
  COUNT(*) AS days_forecast,
  MIN(DATE(forecast_timestamp)) AS first_day,
  MAX(DATE(forecast_timestamp)) AS last_day,
  ROUND(SUM(forecast_value)) AS forecast_sessions_16d,
  ROUND(SUM(prediction_interval_lower_bound)) AS lower_sum_16d,
  ROUND(SUM(prediction_interval_upper_bound)) AS upper_sum_16d
FROM forecast
```

| Forecast made on 2021-01-15 | Sessions 2021-01-16 to 2021-01-31 | Implied landing |
| --------------------------- | --------------------------------- | --------------- |
| Model forecast (median)     | 65,677                            | 124,170         |
| Sum of daily lower bounds   | 46,519                            | 105,012         |
| Sum of daily upper bounds   | 85,164                            | 143,657         |
| Actual                      | 60,125                            | 118,618         |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). Implied landing = 58,493 sessions to date + the 16-day figure. Daily bounds are summed, which gives a conservative envelope, not a true interval on the sum.

The model landed at +4.7%, against +1.9% for the run rate. That is the honest lesson of a 92-day sample. With two and a half months of history, a seasonal model has seen one December and no January. What the model adds is the envelope, 105,012 to 143,657. It contains the actual 118,618. On the 15th, it tells a sponsor that the month is on track, within a wide range. Over a full year of history, the weekly and yearly components take over. The run rate then tends to fall behind on months with a holiday in them. Forecasting the month-end landing: prediction and confidence interval runs the same comparison per market and shows how the interval narrows as the month advances.

### Is the forecast reproducible?

The forecast was reproducible between identical calls on the public sample, but not between different calls. `AI.FORECAST` runs Google's pretrained TimesFM model. Its reference says nothing about reproducibility. Rerun on 2026-10-15, the 16-day statement returned the same 65,677 sessions. The same history, forecast in one call with two other cut-off dates, returned 65,178. The series and the horizon were identical; only the call differed. The gap of 499 sessions is under 0.5% of the landing, well inside the envelope. It still matters to a committee that compares this week's forecast with last week's. Store each forecast with its date and the exact call that produced it. Compare two forecasts only when the call is the same. A full recomputation with a different set of series starts a new history of forecasts.

## Explaining the why: decomposing a KPI change by market, channel, and device

A KPI change is explained by decomposing it. The difference between two periods is split across the values of one dimension. Each value's share of the change is then compared with its share of the base. If desktop carries 59% of the drop and 58% of the sessions, desktop explains nothing. If a market carries 40% of the drop and 5% of the sessions, the investigation starts there.

```sql
WITH sessions AS (
  SELECT
    CASE WHEN _TABLE_SUFFIX < '20210101' THEN 'December 2020' ELSE 'January 2021' END AS month,
    device.category AS device,
    CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING)) AS session_id
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
  WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20210131'
),
by_device AS (
  SELECT
    device,
    COUNT(DISTINCT IF(month = 'December 2020', session_id, NULL)) AS sessions_dec,
    COUNT(DISTINCT IF(month = 'January 2021', session_id, NULL)) AS sessions_jan
  FROM sessions
  GROUP BY device
)
SELECT
  device,
  sessions_dec,
  sessions_jan,
  sessions_jan - sessions_dec AS delta,
  ROUND(100 * (sessions_jan - sessions_dec) / sessions_dec, 1) AS delta_pct,
  ROUND(100 * (sessions_jan - sessions_dec) / SUM(sessions_jan - sessions_dec) OVER (), 1) AS share_of_total_change_pct
FROM by_device
ORDER BY delta
```

| Device  | Sessions, December 2020 | Sessions, January 2021 | Change | Change in % | Share of total change |
| ------- | ----------------------- | ---------------------- | ------ | ----------- | --------------------- |
| desktop | 77,488                  | 68,649                 | -8,839 | -11.4%      | 59.0%                 |
| mobile  | 52,900                  | 47,088                 | -5,812 | -11.0%      | 38.8%                 |
| tablet  | 2,980                   | 2,643                  | -337   | -11.3%      | 2.2%                  |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). Sessions are distinct over each month. So the January total of the three rows, 118,380, differs from the 118,618 sum of daily counts.

The sample gives a textbook negative result. The three devices fell by 11.0% to 11.4%. So the 14,988 sessions lost between December and January are not a device story. The decomposition has done its job by closing a door. The next dimensions to open are market and channel, and the likely answer is seasonality after the December peak. **Contribution analysis** is a method that compares a metric between a test period and a control period and ranks the segments of one or several dimensions by how much of the difference they carry, including segments defined by a combination of values. BigQuery ML runs it as a model type. The statement below follows the documentation consulted on 2026-10-15. Like the ARIMA_PLUS model, it is not executed here.

```sql
CREATE OR REPLACE MODEL `your_project.your_dataset.sessions_drop_contribution`
OPTIONS (
  MODEL_TYPE = 'CONTRIBUTION_ANALYSIS',
  CONTRIBUTION_METRIC = 'SUM(sessions)',
  IS_TEST_COL = 'is_january',
  DIMENSION_ID_COLS = ['country', 'device', 'medium'],
  MIN_APRIORI_SUPPORT = 0.02
) AS
SELECT
  geo.country AS country,
  device.category AS device,
  traffic_source.medium AS medium,
  _TABLE_SUFFIX >= '20210101' AS is_january,
  COUNT(DISTINCT CONCAT(user_pseudo_id, '-', CAST((SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS STRING))) AS sessions
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201201' AND '20210131'
GROUP BY country, device, medium, is_january;

SELECT contributors, metric_test, metric_control, difference, relative_difference, unexpected_difference, apriori_support
FROM ML.GET_INSIGHTS(MODEL `your_project.your_dataset.sessions_drop_contribution`)
ORDER BY ABS(unexpected_difference) DESC
LIMIT 20;
```

The column that matters is `unexpected_difference`: the part of a segment's change that its size did not predict. A segment with a large difference and a small unexpected difference is just big. A segment with a small difference and a large unexpected one is the explanation. Explaining the why: decomposing a KPI change by market, channel, and device runs the three dimensions on the sample. It shows how to read the ranked output without over-interpreting a pair of small values.

## Measuring traffic from ChatGPT and Perplexity in GA4 and BigQuery

GA4 measures traffic from AI assistants through a default channel named AI Assistant. Google's channel documentation defines it by a medium exactly equal to `ai-assistant`. A referrer on Google's own list of assistants also qualifies. The documentation names ChatGPT, Gemini, Copilot, DeepSeek, and Grok as examples. It excludes AI Overviews and AI Mode, which stay in organic search. The list of referrers is not published.

The BigQuery export does not store the channel grouping. It stores `traffic_source.source` and `traffic_source.medium`, the source that first acquired the user. Google's export schema also documents two records. `collected_traffic_source` holds the event-level source; `session_traffic_source_last_click` holds the session's last-click source. To measure the channel in SQL, you rebuild the rule from source and medium. Your own list of referrer domains completes it. The query below applies that rule to the public sample and returns nothing. That is the correct answer for 2020-2021: none of these assistants sent web traffic then.

```sql
SELECT
  traffic_source.source AS source,
  traffic_source.medium AS medium,
  COUNT(DISTINCT user_pseudo_id) AS users
FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
  AND REGEXP_CONTAINS(LOWER(CONCAT(IFNULL(traffic_source.source, ''), ' ', IFNULL(traffic_source.medium, ''))),
      r'chatgpt|openai|perplexity|copilot|gemini|bard|claude|bing\.com/chat|you\.com')
GROUP BY source, medium
ORDER BY users DESC
```

| Source            | Medium | Users |
| ----------------- | ------ | ----- |
| (no row returned) |        | 0     |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data). The sample predates the assistants; the query is the method, not a benchmark.

On a current property, the same query returns a short list, and the first decision is which rows count. `chatgpt.com / referral` is unambiguous; a `copilot` medium set by a campaign is not. The second decision is where to look for the effect. An assistant's visit often lands on a product or support page. It converts at a different rate and may come back as direct. [Measuring traffic from ChatGPT, Perplexity, and Copilot in GA4](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/measure-chatgpt-perplexity-traffic-ga4) answers those questions, with the referrer list to maintain and the landing-page view that makes the channel legible.

## A governed model before any assistant: why the answer depends on it

An assistant answering on a Power BI model is only as right as the model's definitions. It does not compute a KPI; it picks a measure and a filter, then phrases the result. Three measures called sessions, an ambiguous relationship, a column with no description: each leaves the assistant a choice. It chooses silently. The condition for a trustworthy answer is therefore not the assistant. It is a governed model.

A **governed semantic model** is a Power BI model whose measures, relationships, descriptions, and synonyms are defined once, versioned in text, reviewed before release, and shared by every report and every assistant that reads them, so that a filter on one market never changes a definition. The discipline that keeps a human report consistent is the one an assistant needs. Three practical consequences follow. One visible measure per KPI, with the variants hidden. A description on every visible table, column, and measure, written for a reader who has never opened the model. A test set of questions with their expected numbers, rerun after each release. The test set is the part most teams skip. It is also the only evidence that the assistant answered the same question the same way last month. A governed model before any assistant: the condition for a trustworthy answer goes through the review checklist and the failure cases observed when the model is not ready.

### Preparing the semantic model for Copilot in Power BI

Copilot in Power BI reads the semantic model through a feature Microsoft calls "Prep data for AI." The feature is in preview, per the documentation updated on 2026-09-16. It has three parts. An AI data schema restricts which tables and columns the assistant sees. Verified answers bind a phrase to a chosen visual. AI instructions give the assistant written context on the business. All three are saved on the semantic model, not on the report, and Desktop supports them on Import models. Microsoft also notes that the behavior is nondeterministic: the same question can get a different answer. Preparing the model does not remove that. It narrows the space in which the assistant can be wrong, which is the most any preparation can do. The settings are also a useful audit. A schema that cannot shrink to 20 columns belongs to a model nobody has governed. [Preparing a Power BI semantic model for Copilot: descriptions, verified answers, instructions](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model/prepare-semantic-model-copilot-power-bi) shows each setting on a GA4 model and which questions it fixes.

## From signal to brief: what a weekly brief needs before anyone writes it

A weekly brief needs four inputs before any sentence is written. The anomalies of the week with their bounds. The month-end forecast with its interval. The decomposition of the largest change. The list of what did not move. Everything in this guide produces one of those four tables, which is the point. The brief is a reading of governed numbers, not a search for them.

The order matters. A brief that opens with the forecast tells a sponsor where the month lands before explaining why. One that opens with an anomaly nobody noticed makes the reader doubt the rest. The brief states what changed, by how much, and against which expectation. Then it names the dimension that carries the change, then what is still unexplained. A brief that cannot name the unexplained part is a press release. Whether a person or a language model writes the paragraph changes the cost, not the inputs. A model writing from unverified numbers writes confident nonsense faster. A weekly brief written from the numbers: from detection to recommendation gives the structure of the brief and the table each paragraph reads. It also sets the rule for what a recommendation may claim.

> **In Lightstack · Available**
>
> Lightstack, by RTB Strategic Analytics (Montpellier, France), recomputes consultancy-grade GA4 analyses every day from the raw BigQuery export and delivers them in Power BI. The governed semantic model described in this guide is included in every pack. Anomaly Detection is included in the Core pack. The month-end forecast, the root-cause explanation, and the weekly brief are included in Lightstack, the last two in the Intelligence module. See [the semantic model](https://www.rtbanalytics.fr/en/platform#model).

## FAQ

### Does GA4 detect anomalies on its own?

GA4 runs automatic anomaly detection on daily, weekly, and hourly data. A Bayesian state-space model trains on 90 days for daily metrics. The result is a card in the interface, on one metric at a time. It shows neither the predicted range nor the dimension behind the change. Custom conditions can add an email alert, but nothing is exported or replayable.

### How do you measure ChatGPT traffic in GA4?

In the interface, the AI Assistant default channel groups sessions whose medium is `ai-assistant`. Sessions whose referrer matches Google's list of assistants join it too. In the BigQuery export, no channel is stored. You filter the source fields on a list of assistant domains you maintain, such as `chatgpt.com` or `perplexity.ai`. You track landing pages separately.

### What does Copilot need to answer correctly on a Power BI model?

Copilot needs one visible measure per KPI and a description on each visible column. Ambiguous questions need a verified answer. Microsoft's "Prep data for AI" tooling is in preview. It stores an AI data schema, verified answers, and AI instructions on the semantic model. Without them, the assistant still answers. It just picks the measure itself.

### Can you forecast sales with BigQuery?

BigQuery ML forecasts any daily series: sessions, orders, or revenue as GA4 measures it. `ARIMA_PLUS` trains a stored model; `AI.FORECAST` runs on a query without one. Both return a prediction interval. On the public sample, the forecast made on 2021-01-15 missed the January landing by +4.7%. Its envelope still contained the actual value.

### What is a contribution analysis?

A contribution analysis splits the change of a metric between two periods across the segments of one or several dimensions. It ranks them by the part of the change their size did not predict. BigQuery ML runs it as the `CONTRIBUTION_ANALYSIS` model type, and `ML.GET_INSIGHTS` returns each segment's difference and unexpected difference. It explains a change; it does not prove a cause.

### Why build a governed model before an AI assistant?

Because an assistant does not compute. It chooses a measure, a filter, and a wording, and it chooses silently when the model is ambiguous. A governed model makes that choice predictable. It has one measure per KPI, descriptions everywhere, and a test set of questions. The assistant inherits the model's quality; it never fixes it.

Each analysis in this guide runs once on the public sample. The useful version runs every morning on your own export, by market and device. Want new analyses like these as they ship? [Get new analyses as they ship](https://www.rtbanalytics.fr/en/blog/anomalies-forecast-governed-model#footer-newsletter-email).

## Sources

- [The CREATE MODEL statement for ARIMA_PLUS models](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-time-series) - Google Cloud, consulted 2026-10-15
- [The AI.FORECAST function](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast) - Google Cloud, page updated 2026-10-13
- [Contribution analysis overview](https://docs.cloud.google.com/bigquery/docs/contribution-analysis) - Google Cloud, page updated 2026-10-13
- [GA4 anomaly detection](https://support.google.com/analytics/answer/9517187) - Google, consulted 2026-10-15
- [GA4 default channel group](https://support.google.com/analytics/answer/9756891) - Google, consulted 2026-10-15
- [Prepare your data for AI to improve Copilot results (preview)](https://learn.microsoft.com/en-us/power-bi/create-reports/copilot-prepare-data-ai) - Microsoft Learn, page updated 2026-09-16
