Skip to main content

Analytics Data API best practice

This page is a work in progress.

You can access GOV.UK GA4 data via the Analytics Data API.

Best practice

Cardinality and sampling

Data extracted from the API can be subject to issues associated with cardinality and sampling.

If you are trying to figure out whether the results of a certain query are impacted by cardinality or sampling, you can use the dataLossFromOtherRow or samplingMetadatas fields in metadata of the response.

Be particularly careful when using same-day data. GA4 data on GOV.UK takes several hours to be processed, so same-day data is often very unreliable. It is usually better to set your date range to exclude today’s data, unless there is a specific reason you need to look at today.

Quotas

Be aware that API queries are subject to the Google Analytics Data API quotas.

This page was last reviewed on 24 April 2024. It needs to be reviewed again on 24 October 2024 .
This page was set to be reviewed before 24 October 2024. This might mean the content is out of date.