I am trying to get the count of total.pageviews of people go through the booking page on website. Here is my query.
SELECT sum( totals.pageviews ) AS Searches,Date
FROM `table*`
WHERE exists (
select 1 from unnest(hits) as hits
where hits.page.pagePath ='booking'
)
and date='20161109'
GROUP BY DATE
But I got way more results than what i got from Google Analytics. Big query result: around 1M GA: around 300,000 This is the GA page that I am trying to match with
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 ontotals.pageViews
. The problem is thattotals.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:This counts the matched pages directly, and will hopefully give the expected numbers.
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 DATEHope this answer can help other people.
Try below
Searches - number of sessions started with booking page as an entry point to website; PageViews - number of pageviews in those (above) sessions
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 wordingSecondly, if to assume that what you need is - count of pageviews of the booking page on the website - the only reasonable answer is below
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