https://www.growthbook.io/ logo
b

busy-air-96466

03/17/2023, 5:18 PM
Hiya, I want a metric of how many times a user clicks a button. If I choose “count” as the metric type, the dialog says I need to return a “value” column. However there isn’t any “value” for the button, only the event that it was clicked. How should I set this up please? (also, thank you so much for the assistance!) Here’s the metric SQL:
SELECT
user_id,
user_pseudo_id as anonymous_id,
TIMESTAMP_MICROS(event_timestamp) as timestamp
FROM
``analytics_xxx.events_*``
WHERE
event_name = 'Main CTA'
AND _TABLE_SUFFIX BETWEEN '20230313' AND '20230319'
Ah! Looks like this maybe works:
SELECT
user_id,
user_pseudo_id as anonymous_id,
TIMESTAMP_MICROS(event_timestamp) as timestamp,
1 as value
FROM
``analytics_xxxxxx.events_*``
WHERE
event_name = 'Main CTA'
AND _TABLE_SUFFIX BETWEEN '20230313' AND '20230319'
h

helpful-application-7107

03/17/2023, 5:40 PM
yep! that should work!
We'll just do
SUM(value)
under the hood to get the total per user (or another custom aggregation if you specify one).
b

busy-air-96466

03/17/2023, 5:41 PM
Thanks! Hmm, my metric looks good, but the experiment isn’t returning any rows…
I now have one experiment using the “Main CTA conversion” which is binomial, and that is showing data. But my second experiment is using “Main CTA count” as its metric and is finding no rows…
h

helpful-application-7107

03/17/2023, 5:45 PM
there should be rows if there are any users in the experiment.
b

busy-air-96466

03/17/2023, 5:47 PM
I am a numpty, I had the wrong experiment id… 🙂
2 Views