https://www.growthbook.io/ logo
#give-feedback
Title
# give-feedback
c

cuddly-journalist-11507

04/24/2023, 7:39 PM
Hello there 👋, I need help with the distinct user_id + page_view. I will use an example to pass the context: I have a result that has 3251 (variable default) and 3761 (new variable) On the Guardrails shows that the metric page_view is granted that total users. It is wrong because I created the page_view metric that a unique user has 1 point as a page visited, no count. How I fix this? I build SQL wrong? SQL page_view:
Copy code
SELECT
  DISTINCT user_id, user_pseudo_id as anonymous_id,
  TIMESTAMP_MICROS(event_timestamp) as timestamp,
  event_params.value.string_value AS page_location,
  1 as value
FROM
  xx.events_*,
  UNNEST(event_params) AS event_params
WHERE
  event_name = 'page_view'
  AND event_params.key = 'page_location'
  AND event_params.value.string_value LIKE '%app.xx.com%'
  AND _TABLE_SUFFIX BETWEEN '{{startYear}}{{startMonth}}{{startDay}}' AND '{{endYear}}{{endMonth}}{{endDay}}'
w

white-fireman-22476

04/25/2023, 9:35 AM
Hi Adriano! I'm not sure if this helps but, DISTINCT will return a row for each distinct combination of all the columns listed in your SELECT. Since you have timestamp listed, the DISTINCT won't be doing much as the timestamps for each page view will be unique. So you can probably just leave the DISTINCT off. In general thought the query looks ok to me. Growthbook will then take this query and run sums per user on it and then average that. I'm not sure I understand what you are seeing that is not what is expected. It might be helpful to you though to understand what is happening by looking at the exact sql that growthbook is running. You can see that in the growthbook UI by going to the metrics page ("/metrics"), clicking on the page_view metric , clicking "Run analysis" or "Refresh data", then clicking on "view queries". Let me know if there is anything else I can do to help you figure this out.
🙌 1
c

cuddly-journalist-11507

04/25/2023, 1:22 PM
Hello James, Now the number is correct, I don't how it's changed. Although I refresh the data yesterday it not is changed but today is fixed. Thanks! =)
e

echoing-continent-65097

04/25/2023, 1:50 PM
Glad to hear. I hope things stay as expected, and feel free to reach out again if they aren't.
10 Views