google-bigquerygoogle-analyticsgoogle-analytics-apiuniversal-analytics

Why is the total time on the site is null for sessions with interaction events?


I am running a query on the UA BigQuery Export and I notice that there are multiple sessions with interaction events that have totals.timeOnSite as null. How is that possible?


Solution

  • There are a few ways for it to happen. But, first of all, since you're looking at the raw data, you have to make sure you're tracking the session ids how google sees them in a custom dimension since GA UA won't give it to you by default.

    If the session is indeed the same (not by using the time between interactional hits), then check if you have other pageviews in the sessions with timeOnSite == null.

    UA has a few weirdly defined dimensions and metrics and there were a few that didn't make sense since they were implemented counter-intuitively. For example, ignoring the interactive events and using only pageviews to calculate time on site, or time on page.

    With the session id in place, you will be able to calculate your own time on site as you define it. Though it's not very pleasant to make time-based calculations in SQL, it should have adequate computational complexity.

    The best precision to calculating time on site and on page would be, of course, via GTM. However, it's considered more of a vanity metric to spend much time on it.