我正在尝试为在会话期间完成特定事件操作的用户创建用户页面路径分析。到目前为止,我已经能够为所有用户创建页面路径-但是我现在正在尝试为联系的用户创建辅助路径分析。
我尽力使用where子句查找解决方案,但所有结果均显示0个结果
SELECT t.page_path,
t.second_page_path,
t.third_page_path,
t.fourth_page_path,
#concact the 4 pages together with a hyphen if a next page exists
CONCAT(t.page_path,IF(t.second_page_path IS NULL,'','*'),
IFNULL(t.second_page_path,''),IF(t.third_page_path IS NULL,'','*'),
IFNULL(t.third_page_path,''),IF(t.fourth_page_path IS NULL,'','*'),
IFNULL(t.fourth_page_path,'')) AS full_page_journey,
#Count total sessions that went down that path after landing
count(sessionId) AS total_sessions
FROM (
SELECT
CONCAT(fullVisitorId,'-', CAST(visitStartTime AS STRING)) AS sessionId,
hits.hitNumber as hitsya,
(SELECT x.value FROM UNNEST(hits.customDimensions) x WHERE x.index = 22) as page_path,
LEAD((SELECT x.value FROM UNNEST(hits.customDimensions) x WHERE x.index = 22)) OVER (PARTITION BY fullVisitorId, visitStartTime ORDER BY hits.hitNumber) AS second_page_path,
LEAD((SELECT x.value FROM UNNEST(hits.customDimensions) x WHERE x.index = 22),2) OVER (PARTITION BY fullVisitorId, visitStartTime ORDER BY hits.hitNumber) AS third_page_path,
LEAD((SELECT x.value FROM UNNEST(hits.customDimensions) x WHERE x.index = 22),3) OVER (PARTITION BY fullVisitorId, visitStartTime ORDER BY hits.hitNumber) AS fourth_page_path
FROM
`PROJECT_NAME.ga_sessions_*`,
UNNEST(hits) AS hits
WHERE
_TABLE_SUFFIX BETWEEN '20190501'
AND '20190505'
AND hits.type='PAGE'
AND REGEXP_CONTAINS(hits.eventInfo.eventAction, r'Contact Us Submission'))t
WHERE t.hitsya=1
#Group by page of hit and all subsequent pages
GROUP BY t.page_path,
t.second_page_path,
t.third_page_path,
t.fourth_page_path,
full_page_journey
ORDER BY total_sessions DESC
我希望只能获得包含该事件的会话
答案 0 :(得分:1)
由于您的条件矛盾,您得到0个结果:
WHERE
_TABLE_SUFFIX BETWEEN '20190501'
AND '20190505'
AND hits.type='PAGE'
AND REGEXP_CONTAINS(hits.eventInfo.eventAction, r'Contact Us Submission'))t
您不能拥有hits.type='PAGE'
,并且不能期望hits.eventInfo.eventAction
中的值。该字段仅包含hits.type='EVENT'
如果您希望与此事件进行会话,则在整个会话中使用子查询来查找它:
WHERE
_TABLE_SUFFIX BETWEEN '20190501'
AND '20190505'
AND hits.type='PAGE'
AND (SELECT COUNT(1)>0
FROM unnest(hits)
WHERE REGEXP_CONTAINS(hits.eventInfo.eventAction, r'Contact Us Submission') )