185 유니버설 애널리틱스와 동일한 정의의 이탈률을 구하기
유니버설 애널리틱스의 “이탈률” (1 페이지뷰만 발생한 세션의 비율)을 구하는 SQL 문입니다.
WITH
master
AS
(
SELECT
event_date, ga_session_id,
COUNT
(*)
AS
pv_by_session
FROM
(
SELECT
event_date
, (
SELECT
value.int_value
FROM
UNNEST(event_params)
WHERE
key
=
'ga_session_id'
)
AS
ga_session_id
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_202011*`
WHERE
event_name =
'page_view'
)
GROUP
BY
event_date, ga_session_id
)
SELECT
event_date,
COUNT
(
DISTINCT
ga_session_id)
AS
sessions,
SUM
(bounce)
AS
bounces
, ROUND(
SUM
(bounce) /
COUNT
(
DISTINCT
ga_session_id) * 100, 2)
AS
bounce_rate_percent
FROM
(
SELECT
event_date, ga_session_id, IF(pv_by_session = 1, 1, 0)
AS
bounce
FROM
master
)
GROUP
BY
event_date
ORDER
BY
1
답글 남기기