Created
March 25, 2023 12:57
-
-
Save nicobrx/a3219f8dfbfdbeed53bbad3ea166af10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
event_date, | |
COUNT(DISTINCT(session_id)) AS sessions, | |
SUM(ga4_resource_page_views) AS ga4_resource_page_views | |
FROM ( | |
SELECT | |
CONCAT(user_pseudo_id,(SELECT value.int_value FROM UNNEST(event_params) WHERE KEY = 'ga_session_id')) AS session_id, | |
COUNT((SELECT value.string_value FROM UNNEST(event_params) WHERE KEY = 'page_location' | |
AND value.string_value LIKE 'https://twooctobers.com/blog/ga4-resources/%')) AS ga4_resource_page_views, | |
PARSE_DATE('%Y%m%d',event_date) AS event_date | |
FROM | |
`[your project].[your GA4 table].events_*` | |
WHERE | |
_table_suffix BETWEEN '20230201' AND '20230228' | |
AND event_name = 'page_view' | |
GROUP BY | |
user_pseudo_id, | |
session_id, | |
event_date | |
) | |
GROUP BY event_date | |
ORDER BY event_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment