Google Big Query page view count does not match with GA page view count

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 06:25:10

After looking a bit more into Google Analytics data, I think that you actually want to count entries in hits that match the condition directly instead of relying on totals.pageViews. The problem is that totals.pageViews represents the number of distinct pages visited within a particular session (if I'm using the correct terminology), which includes pages that don't match your filter. I think you want something like this instead:

SELECT
  COUNT(*) AS Searches,
  Date
FROM `table*`, UNNEST(hits) AS hit
WHERE hit.page.pagePath = 'booking';

This counts the matched pages directly, and will hopefully give the expected numbers.

Try below

SELECT
  date,
  COUNT(*) AS Searches,
  SUM(totals.pageviews) as PageViews
FROM `table*`, UNNEST(hits) AS hit
WHERE hit.page.pagePath = 'booking'
AND hit.hitNumber = 1
GROUP BY date

Searches - number of sessions started with booking page as an entry point to website; PageViews - number of pageviews in those (above) sessions

I would like to have total(totals.pageview ) for the booking page on the website. how many times that the booking page has been viewed

First - total(totals.pageview) - doesn't help in identifying what really you need as you are assuming that using total.pageviews field is correct, which seems is not - at least based on the rest of your wording

Secondly, if to assume that what you need is - count of pageviews of the booking page on the website - the only reasonable answer is below

SELECT
  date,
  COUNT(1) AS BookingPageViews
FROM `table*`, UNNEST(hits) AS hit
WHERE hit.page.pagePath = 'booking'
GROUP BY date

Finally, if you still getting numbers different from what you expect - you need to revisit your what actually you are looking for. It might be that the number that you see in GA represents metric that is different from what you think it represents. This is the only explanation I would see

I found the solution solve this problem:

SELECT count(totals.pageviews) AS Searches,Date FROM table, UNNEST(hits) as hits WHERE hits.page.pagePath ='/booking' and hits.type='PAGE' GROUP BY DATE

Hope this answer can help other people.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!