問題可能是其中兩個字符串"account=true"
和"subscribed"
存在於同一個pagePath
的情況下,就這樣。解決它的
的一種方法是通過改變匹配條件,如:
SELECT
EXACT_COUNT_DISTINCT(CASE WHEN hits.type = "PAGE" THEN CONCAT(fullvisitorid,
STRING(visitid), hits.page.pagepath) END) AS UniquePageViews,
CASE WHEN (REGEXP_MATCH (hits.page.pagePath, '(account=true)') AND NOT REGEXP_MATCH (hits.page.pagePath, '(subscribed)')) THEN "Accounts"
WHEN (REGEXP_MATCH (hits.page.pagePath, '(subscribed)') AND NOT REGEXP_MATCH (hits.page.pagePath, '(account=true)')) THEN "Signups"
WHEN (REGEXP_MATCH (hits.page.pagePath, '(subscribed)') AND REGEXP_MATCH (hits.page.pagePath, '(account=true)')) THEN "Both"
ELSE "Others" END AS Goals
FROM
[mydata.ga_sessions_20150506]
GROUP BY
Goals
如果我強迫的條件僅匹配"account=true"
而不是"subscribed"
。
作爲一個例子,這是我對我們的ga_sessions數據集進行測試:
SELECT
exact_count_distinct(CASE WHEN hits.type = "PAGE" THEN CONCAT(fullvisitorid, STRING(visitid), hits.page.pagepath) END) AS UniquePageViews,
CASE WHEN (REGEXP_MATCH (hits.page.pagePath, '(colcci)') AND NOT REGEXP_MATCH (hits.page.pagePath, '(lacoste)')) THEN "colcci"
WHEN (REGEXP_MATCH (hits.page.pagePath, '(lacoste)') AND NOT REGEXP_MATCH (hits.page.pagePath, '(colcci)')) THEN "lacoste"
WHEN (REGEXP_MATCH (hits.page.pagePath, '(lacoste)') AND REGEXP_MATCH (hits.page.pagePath, '(colcci)')) THEN 'both'
ELSE "Others" END AS Goals
FROM [40663402.ga_sessions_20150506]
GROUP BY
Goals
希望這有助於。任何問題都會讓我們知道,
我得到的結果與以前相同。也許是獨特的網頁瀏覽量的問題? 我測試了以下查詢uniquepageview,我得到了準確的數字。但我不確定如何在我的示例中包含此查詢。 SELECT COUNT(1)作爲unique_pageviews FROM(SELECT hits.page.pagePath, hits.page.pageTitle, fullVisitorId, visitNumber, COUNT(1)擊中 FROM [MY_TABLE] WHERE hits.type = '頁面' GROUP BY hits.page.pagePath, hits.page.pageTitle, fullVisitorId, visitNumber ) – sam123
不知道什麼是錯的呢。也許如果你嘗試添加: '其中hits.page.pagepath包含(「account = true&subscribed」或(「account = true」,而不是「subscription」)可能會解決但不確定爲什麼第一個查詢不起作用。 –
快速的問題,你可以分享結果與我們的查詢我建議你和你說的是正確的? –