big-breakfast-90296
06/03/2025, 6:09 AMWITH growthbook_events AS (
 SELECT
   user_pseudo_id AS unique_user_id,
    (CASE WHEN ep.key = 'experiment_id' THEN CAST(ep.value.int_value AS STRING) END) AS experiment_id,
    (CASE WHEN ep.key = 'variation_id' THEN ep.value.int_value END) AS variation_id,
    (CASE WHEN ep.key = 'gb_user_id' THEN CAST(ep.value.int_value AS STRING) END) AS gb_user_id
 FROM
   `mydataset.events_*`,
   UNNEST(event_params) AS ep
 WHERE
   event_name = 'growthBook'
   AND _TABLE_SUFFIX BETWEEN '20250416' AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
 GROUP BY
   unique_user_id, experiment_id,variation_id, gb_user_id
)
And then using the following query to get  users who were to be counted as test users based on the defined activation metric.
activation_ids AS (
 SELECT
 user_pseudo_id AS unique_user_id
 FROM `mydataset.events_*`
where event_name = 'activation_metric'
AND _TABLE_SUFFIX BETWEEN '20250416' AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
GROUP BY
unique_user_session_id
)
And then join them
SELECT
 g.unique_user_id,
 g.experiment_id,
 g.variation_id,
 g.gb_user_id
FROM
 growthbook_events AS g
JOIN
 activation_ids AS act
ON
 g.unique_user_id = act.unique_user_id
WHERE
 g.experiment_id = 'my_experiment'
I'm seeing slightly different unique user counts per variant compared to the Growthbook dashboard.
Is counting distinct user_pseudo_id the correct approach?fresh-football-47124
fresh-football-47124
fresh-football-47124