Search code examples
google-analyticsgoogle-bigquerygoogle-analytics-api

Why would totals.visits be NULL on a row where totals.newVisits is 1


I'm running a query to pull source, medium, some custom dimensions, new sessions (totals.newVisits), sessions (totals.visits) and session duration (totals.timeOnSite).

I get some results where there is a value for totals.newVisits, but not totals.visits. How would that be possible - isn't a new visit supposed to be a subset of all visits?


Solution

  • You have to see these 2 variables ("totals.visits" and "totals.newVisits") as indicators (booleans).

    Here, we want to know whether the user have already gone to the website before the visit or he is a returning visitor (totals.newVisits) and whether the user have done an interaction during the session or not (totals.visits).

    In that case, it's 2 independent variables.

    That is why Google specify these variables like :

    The value is null if there are no interaction events in the session.

    or

    If this is the first visit, this value is 1, otherwise it is null.

    You have to really stick into Google's variables definitions : BigQuery variable dictionary