192 첫 방문 시 매체와 랜딩 페이지별 LTV 확인하기
첫 방문의 매체와 랜딩 페이지별 사용자 수 및 LTV를 가져오는 SQL 문입니다.
WITH
ltv
AS
(
SELECT
user_pseudo_id,
MAX
(user_ltv.revenue)
AS
ltv,
MAX
(traffic_source.medium)
AS
first_media
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_202101*`
GROUP
BY
user_pseudo_id)
, flp
AS
(
SELECT
user_pseudo_id
, (
SELECT
value.string_value
FROM
UNNEST(event_params)
WHERE
key
=
'page_location'
)
AS
page_location
FROM
`bigquery-
public
-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE
event_name =
"first_visit"
)
SELECT
first_media, first_landing_page,
COUNT
(
DISTINCT
user_pseudo_id)
AS
users,
SUM
(ltv)
AS
ltv
,
SUM
(ltv)/
COUNT
(
DISTINCT
user_pseudo_id)
AS
avg_ltv
FROM
(
SELECT
ltv.first_media, flp.page_location
AS
first_landing_page, ltv.user_pseudo_id, ltv.ltv
FROM
ltv
JOIN
flp USING(user_pseudo_id)
WHERE
ltv.first_media <>
"(data deleted)"
)
GROUP
BY
first_media, first_landing_page
ORDER
BY
3
DESC
답글 남기기