Skip to main content

How to Adjust Detection Thresholds

The module ships with default thresholds that determine which series are trained and which signals are considered reliable. These defaults work for most GA4 properties, but you may want to adjust them when:

  • Your property is newer and does not yet have 60 days of event history
  • You want to monitor more than 5 events in ga4_events
  • You are getting too many alerts from low-traffic series and want to reduce noise
  • You have a high-traffic property and want to apply stricter quality filters

This guide walks through the change end-to-end: opening a Dataform workspace, creating a threshold override file, running the pipeline, and committing the result.

What you will need

  • The anomaly detection module enabled in your project ("enabled": true in includes/custom/modules/anomaly_detection/config.json)
  • Familiarity with the Getting Started guide, in particular the thresholds described in the Adjust the thresholds section

Step 1: Open a workspace in Dataform

Go to console.cloud.google.com, navigate to BigQueryDataform, and open your repository.

From the Workspaces tab, create a new development workspace by clicking Create workspace. Give it a name (e.g. anomaly-adjust-thresholds) and click Create.

Step 2: Create the threshold override file

Navigate to includes/custom/modules/anomaly_detection/cases/ and open the case file you want to update (ga4_events.yaml or ga4_sessions.yaml). If the file does not exist yet, create it.

You only need to include the parameters you want to change. The module merges this file over the core defaults: everything you omit stays as-is.

Example: lower the training bar to include more events and expand the top N limit:

training_min_series_days: 30
training_min_series_avg: 10
top_n_time_series: 20
detection_min_series_avg: 20

This tells the module to train on events with at least 30 days of history (instead of 60) and at least 10 average daily events (instead of 20). It also expands the pool to the top 20 events by volume and lowers the detection reliability bar to match.

Example: reduce alert noise on a low-traffic site (ga4_sessions):

training_min_series_avg: 2
detection_min_series_avg: 30

This allows channels with very low session volume to enter training, and lowers the threshold at which a channel is marked as reliable for alerting.

Start with one change at a time

Lowering thresholds increases the number of series the model trains, which increases BigQuery ML cost and run time. Change one parameter, run the pipeline, and review the output before adjusting further.

Step 3: Run the workflow

In the top-right of the Dataform editor, click Start execution.

In the execution panel:

  • Select Full refresh: threshold changes affect model training, so the model must be rebuilt from scratch
  • Under Tags or actions to run, filter by the tag module_anomaly_detection to run only this module

Click Start execution and wait for the run to complete. You can follow the progress in the execution log. Each step of the pipeline appears as a separate action:

  1. int_anomaly_detection_{case}_time_series: builds the training data with the updated series selection
  2. int_anomaly_detection_{case}_model_training: retrains the BigQuery ML model with the new series pool
  3. int_anomaly_detection_{case}_anomalies: scores the detection window against the new model
  4. anomaly_detection_report: updates the unified output table

If any action fails, click on it in the log to see the error details.

Step 4: Review the output

Before committing, verify that the changes produced the expected results. Open BigQuery and check anomaly_detection_report:

  • Filter by source = 'anomaly_detection' to see scored rows
  • Check is_strong_series: you should see more series marked true if you lowered thresholds, or fewer if you raised them
  • Review which series are now present compared to the previous run

If the results look off, adjust the parameters and re-run before committing.

Step 5: Commit your changes

Once the results look correct, go back to your Dataform workspace and click Commit in the top bar.

Write a short commit message describing what you changed, for example:

feat: lower training thresholds for ga4_events to include more events

Click Commit to save your changes to the repository. If your project uses a CI/CD pipeline or scheduled Dataform releases, your change will be picked up automatically on the next run.

Next steps