late-dentist-52023
05/07/2025, 12:57 AMlate-dentist-52023
05/07/2025, 1:01 AMcommon_table
you would just replace with a really common event table (e.g. page/screen view) that any active user would trigger. It is essentially your "activation" metric.
with
pseudo_experiment_assignment as (
select
common_table.user_id
, 'faux_a_a_experiment' as experiment_id
, case when avg(random()) < 0.5 then 'A' else 'B' end as variation_id
, min(common_table.event_timestamp) as timestamp
from common_table
where common_table.event_timestamp > '{{ startDate }}'
and common_table.event_timestamp < '{{ endDate }}'
group by 1,2
order by random()
limit 200000
)
select *, experiment_id as experiment_name, variation_id as variation_name
from pseudo_experiment_assignment
You could add other where clauses if you wanted to evaluate some subset of your system -- or if you wanted to filter out users that are in experiments or any other condition relevant to your business.
The limit is also helpful in that you can use a relevant value to ensure your sample size is appropriate for your typical experiment.helpful-application-7107
05/07/2025, 1:45 AMboundless-air-30371
05/08/2025, 9:52 PMlate-dentist-52023
05/08/2025, 10:43 PMand common_table.user_id not in (select user_id from users_in_experiments_cte)
We have existing systems that handle experiment assignment, so a query I would write would be specific to our company. If you are using growthbook to run the experiment @helpful-application-7107 is better positioned to suggest a good query.late-dentist-52023
05/08/2025, 10:45 PMhelpful-application-7107
05/08/2025, 10:49 PMhelpful-application-7107
05/08/2025, 10:50 PMboundless-air-30371
05/08/2025, 11:11 PM