{"id":5716,"date":"2023-08-09T14:21:05","date_gmt":"2023-08-09T11:21:05","guid":{"rendered":"https:\/\/trackingchef.com\/?p=5716"},"modified":"2024-10-28T19:05:59","modified_gmt":"2024-10-28T16:05:59","slug":"how-to-get-count-of-session-in-bigquery-for-google-analytics-4","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/google-analytics\/how-to-get-count-of-session-in-bigquery-for-google-analytics-4\/","title":{"rendered":"How to Get Count of Session in Bigquery for Google Analytics 4"},"content":{"rendered":"\n
Back in the old days of universal analytics, there was a report that not that many users knew about or used, but could hold some interesting insights, i.e. the “Frequency & Recency” report which is absent from google analytics 4.<\/p>\n\n\n\n This report used to show the “Count of Sessions” dimension , i.e. “buckets” of the nth number of session of a unique user. What I liked about this report is that it would give you a view on engagement and stickiness that other metrics didn’t show, what I didn’t like about it is that it showed this dimension with a metrics of sessions, instead of users which would have been more accurate and helpful. <\/p>\n\n\n\n As of now, this dimension is not supported in GA4 and I wouldn’t hold my breath waiting for Google to add it, so it’s up to us to recreate it. Since there is no way to build it in the GA4 interface itself, you’ll need to use BigQuery and run the following query:<\/p>\n\n\n\n <\/p>\n\n\n\n<\/figure>\n\n\n\n
SELECT\nuser_pseudo_id,\nCOUNTIF(event_name = \"session_start\") as num_of_sessions\nFROM 'myproject.analytics_343884170.events_*' \/\/change to your project and table id<\/span><\/span>\n where\n_table_suffix between '20230805' and '20230805' \/\/change to <\/span><\/span>the date frame you want\ngroup by 1,2\norder by num_of_sessions desc\n<\/code><\/pre>\n\n\n\n