Hi, I'm wondering how we can query GA4 to get the ...
# ask-questions
Hi, I'm wondering how we can query GA4 to get the
event AND get what experiment it was tied to. So far, I have this query which pulls the
and what experiment it is along with what variation. What I can't figure out is how to tie that to the
Copy code
  user_pseudo_id AS anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) AS timestamp,
  (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'experiment_id') AS experiment_id
  event_name = 'experiment_viewed'
  (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'experiment_id') = 'products-aa'
  (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'variation_id') = 0
I can just get the purchase event by itself too using
event_name = 'purchase'
. I feel I'm close, thanks for any help you can offer!
Hi Erik, your request is in our support queue and we'll send an update as soon as we can
👍 1
Hi Erik, we are still working through our support queue and haven't forgotten about this! We'll likely have an update for you tomorrow.
Hi Erik - the purchase would be added as a metric
the way GrowthBook works is by using that generic query to select all the users who saw the experiment, then we join to the metrics that you care about (purchases, page views, whatever)
so you would define a ‘purchase’ metric generically for reuse
@fresh-football-47124 Thanks for the info. So we can't get that info directly from BigQuery then with 1 query?
you can get it in one query
we do this automatically for you when getting the experiment data
what is the use case for wanting it in one query?
you could add it as a dimension if you want
@fresh-football-47124 Our marketing director likes to run his own queries against our data in our actual site database and would benefit from running this type of query in BigQuery as well outside of GrowthBook.
we give you the raw queries we use for any data shown
Sorry for the ignorance. How can I find the query for what I am asking for above?
Hi Erik, no worries at all! We're here to help. What Graham was describing is the process of combining the Experiment Assignment Query with the Metric Query. This creates a joined query that will derive the metric results from users who were assigned to the experiment. You can find all such queries by following these steps: 1. Go to a running experiment in GrowthBook. 2. Click on the '3 Dots' menu within the Analysis Settings. 3. Look for the ​`View Queries`​ option and select it. Your colleague should be able to copy this SQL code and run it directly on the database.
Here are some screenshots of sample data to help you find this, in the order of the steps listed above: