Rachel
Rachel

Reputation: 181

Google BigQuery Return Users Count

I am trying to get number of return users from Google Big Query to match with what I have in GA.

The query I wrote is:

SELECT 
  SUM(CASE WHEN totals.newVisits IS NULL THEN 1 ELSE 0 END) AS Return_Visitors
FROM `table`
WHERE date='20161109'

But I got more return users than what I got from GA.

I found the the definition of totals.newVisits is "Total number of new users in session (for convenience). If this is the first visit, this value is 1, otherwise it is null." That's why I used when totals.newVisits is null. Is my logic right?

Thank you

Upvotes: 1

Views: 3248

Answers (1)

Willian Fuks
Willian Fuks

Reputation: 11777

Does it work for you?

select
SUM(CASE WHEN totals.newVisits IS NULL THEN 1 ELSE 0 END) AS Return_Visitors
FROM `table`
where totals.visits = 1
and date = '20161109'

Upvotes: 2

Related Questions