190 조회 시 CVR이 높아지는 페이지를 포괄적으로 탐색하기
여러 콘텐츠에 대해 “표시한 사용자”, “표시하고 전환한 사용자”, “표시하지 않은 사용자”, “표시하지 않았지만 전환한 사용자”를 시각화하여, 어떤 콘텐츠를 표시했을 때 사용자 단위 전환율이 어떻게 변화하는지 포괄적으로 시각화하는 SQL 문입니다.
WITH
master
AS
(
SELECT
DISTINCT
user_pseudo_id
AS
cid
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_202101*`
), pvu
AS
(
SELECT
*
FROM
(
SELECT
user_pseudo_id
AS
cid
, (
SELECT
value.string_value
FROM
UNNEST(event_params)
WHERE
key
=
"page_title"
)
AS
page
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_202101*`)
WHERE
REGEXP_CONTAINS(page, r
"^(Home|Men's\s/\sUnisex\s\|\sApparel|Sale\s\|\sG|New\s\|\sG|Small\sGoods\s\|\sLifestyle|YouTube\s\|\sS|Bags\s\|)"
)
IS
true
group
by
cid, page
), cvu
AS
(
SELECT
DISTINCT
user_pseudo_id
AS
cid, 1
AS
cv
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_202101*`
WHERE
event_name =
"purchase"
)
SELECT
*, ROUND(view_user_cvr / non_view_user_cvr, 1)
AS
difference_ratio
FROM
(
SELECT
*
, ROUND(non_view_cv_users / non_view_users, 4)
AS
non_view_user_cvr
FROM
(
SELECT
*, ROUND(view_cv_users / view_users, 4)
AS
view_user_cvr
, (
SELECT
COUNT
(
DISTINCT
cid)
FROM
master) - view_users
AS
non_view_users
, (
SELECT
SUM
(cv)
FROM
cvu) - view_cv_users
AS
non_view_cv_users
FROM
(
SELECT
page,
COUNT
(
DISTINCT
view_users)
AS
view_users,
SUM
(cv)
AS
view_cv_users
FROM
(
SELECT
master.cid
AS
all_users, pvu.cid
AS
view_users, pvu.page, cvu.cv
FROM
master
LEFT
JOIN
pvu
USING (cid)
LEFT
JOIN
cvu
USING (cid)
WHERE
page
IS
NOT
NULL
)
GROUP
BY
page)))
ORDER
BY
2
DESC
답글 남기기