https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
s

silly-fall-70535

08/12/2023, 1:06 AM
I've just launched my first experiment. Basically trying to test different sizes for our CTA button. The page is on /, but when you click on the button it goes to /newpage. We are using google analytics... I see I can choose page_view as a metric goal, but I don't quite understand how "page_view" works (page view appears to be a binomial)... Is it easy to create a metric where it is count of pageview=newpage? Or do I need to create a new metric in the app and send an event to GA?
f

fresh-football-47124

08/12/2023, 1:06 AM
Should be pretty easy to do that
the page view event in GA should have the actual page
so you can make a new metric for that particular page
s

silly-fall-70535

08/12/2023, 1:11 AM
Okay, I'll try to see how to do that
i'll try with this query builder
f

fresh-football-47124

08/12/2023, 1:12 AM
let me know if you need help with the query
s

silly-fall-70535

08/12/2023, 1:14 AM
Copy code
SELECT
  user_id,
  user_pseudo_id as anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) as timestamp
FROM
  `pathology-699c4`.`analytics_341966914`.`events_*`
WHERE
  event_name = 'page_view'  
  AND event_params.key = 'page_location'
  AND event_params.value='<https://pathology.gg/tutorial>'
  AND _TABLE_SUFFIX BETWEEN '{{startYear}}{{startMonth}}{{startDay}}' AND '{{endYear}}{{endMonth}}{{endDay}}'
Is this hypothetically correct?
Cannot access field key on a value with type ARRAY<STRUCT<key STRING, value STRUCT<string_value STRING, int_value INT64, float_value FLOAT64, ...>>> at [11:24]
f

fresh-football-47124

08/12/2023, 1:15 AM
mostly - BigQuery does this weird storing JSON values thing, so if you’re referencing event_params.key, you have to expand the JSON
Copy code
UNNEST(event_params) AS page_view_params
then you can do where
page_view_params.key = "whatever"
(the UNNEST will go in the from section)
s

silly-fall-70535

08/12/2023, 1:18 AM
yeah i figured... getting another syntax error though
Copy code
SELECT
  user_id,
  user_pseudo_id as anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) as timestamp,
  UNNEST(event_params) AS page_view_params
FROM
  `pathology-699c4`.`analytics_341966914`.`events_*`
WHERE
  event_name = 'page_view'  
  AND event_params.key = 'page_location'
  AND event_params.value='<https://pathology.gg/tutorial>'
  AND _TABLE_SUFFIX BETWEEN '{{startYear}}{{startMonth}}{{startDay}}' AND '{{endYear}}{{endMonth}}{{endDay}}'
Syntax error: Expected ")" but got keyword UNNEST at [5:7]
f

fresh-football-47124

08/12/2023, 1:18 AM
UNNEST goes in the from section
s

silly-fall-70535

08/12/2023, 1:19 AM
Ohhh my bad
lol
f

fresh-football-47124

08/12/2023, 1:19 AM
and event_params.key/value will need to change too the aliased name
page_view_params.key/value
s

silly-fall-70535

08/12/2023, 1:20 AM
Copy code
SELECT
  user_id,
  user_pseudo_id as anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) as timestamp
FROM
  `pathology-699c4`.`analytics_341966914`.`events_*`,
  UNNEST(event_params) AS page_view_params
WHERE
  event_name = 'page_view'
  AND page_view_params.key = 'page_location'
  AND page_view_params.value = '<https://pathology.gg/tutorial>'
  AND _TABLE_SUFFIX BETWEEN '{{startYear}}{{startMonth}}{{startDay}}' AND '{{endYear}}{{endMonth}}{{endDay}}'
okay finally got it
Copy code
SELECT
  user_id,
  user_pseudo_id as anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) as timestamp
FROM
  `pathology-699c4`.`analytics_341966914`.`events_*`,
  UNNEST(event_params) AS page_view_params
WHERE
  event_name = 'page_view'
  AND page_view_params.key = 'page_location'
  AND page_view_params.value.string_value = '<https://pathology.gg/tutorial>'
  AND _TABLE_SUFFIX BETWEEN '{{startYear}}{{startMonth}}{{startDay}}' AND '{{endYear}}{{endMonth}}{{endDay}}'
f

fresh-football-47124

08/12/2023, 1:21 AM
cool
s

silly-fall-70535

08/12/2023, 1:21 AM
hmm no results though 😕
maybe i have something off here... will debug further
f

fresh-football-47124

08/12/2023, 1:22 AM
you can run it, without the date placeholders, in your bigQuery console to figure out whats up
s

silly-fall-70535

08/12/2023, 1:23 AM
yeah i'm changing the page_view = to a LIKE
okay this is great... gonna create a bunch for different pages...
is there a way to generate a collection of metrics?
So I can add a collection rather than metrics one by one?
f

fresh-football-47124

08/12/2023, 1:28 AM
There are some ways to do this with variables
but the set is quite limited atm - what did you have in mind?
s

silly-fall-70535

08/12/2023, 1:30 AM
For example, I may have a collection of metrics for our multiplayer modes, single player, etc...
Maybe performance metrics
So it would be nice to be able to group metrics this way so when reviewing experiments it is a bit easier to filter
f

fresh-football-47124

08/12/2023, 1:31 AM
You might want to use dimensions or segments for doing that level of definitions
👀 1
14 Views