analytics
-
How GA4 Counts Millions of Users with 12 Kilobytes: The HyperLogLog Algorithm
Open any GA4 report and look at Total Users. Then run COUNT(DISTINCT user_pseudo_id) in your BigQuery export. The numbers won't match. They're usually within a percent or two, and there is no setting that makes them. That gap isn't a bug, and it isn't sampling. It's a deliberate engineering decision: GA4 never actually counts your users. It estimates them, using a probabilistic data structure called HyperLogLog++ that can approximate the number of unique items in a set of any size using a fixed 12 KB of memory.