How does GA.js determine time on site?

Skip to first unread message

John H.

Dec 14, 2009, 12:56:36 PM12/14/09
to google-analytics-api - GA Data Export API
Ok, Somehow I am missing it here.
I understand that GA.js records 2 cookies __utmb & __utmc with one
cookie ending when user leaves site. The question I am confused is how
is the time the person leaves the site captured and returned to


Dec 15, 2009, 4:38:58 PM12/15/09
to google-analytics-api - GA Data Export API
+1 vote for a good explanation on this. If someone does pick this
glove up, please refer also to application reporting only events.



Dec 15, 2009, 5:54:42 PM12/15/09
to google-analytics-api - GA Data Export API

Happy to help clarify.

Google Analytics collects time stamps for each hit (server request)
generated by the ga.js. Each hit has a certain type and only:
pageviews, events, transactions and items are included in the
ga:timeOnSite calculation.

ga:TimeOnSite is visit based where a visit increments:
- when the browser closes
- if > 30 mins has elapsed between time stamps
- the end of the day

In ga.js, __utmb is a cookie set to expire for 30 minutes in the
future. __utmc is a session cookie which expires when the browser
closes. Each tracking request checks both cookies and if either isn't
present the visit is incremented. Ending the session at the end of the
day happens when your data is processed and is defined by midnight of
the time configured for an individual profile.

To arrive at ga:timeOnSite, GA sums the deltas between each timestamp
(for the hit types above) in a visit. The main edge cases is the last
hit in a session, where we can't compute the delta. In that case the
quantum of time between the last hit and the session end is not added
to the calculation.

Hope that clarifies the question :)

Brandt Dainow

Dec 16, 2009, 6:01:21 AM12/16/09
to google-analytics-api - GA Data Export API
Hi - can you add further qualification to the "end of the day" - are
you saying that if someone arrives at 23:55, then requests another
page at 00:15, this will be recorded as two visits? If so, what
constitutes "end of the day" - is it GMT time, local time at browser,
local time at web server, or local time at GA server? And in all
cases, how is daylight saving handled?


Dec 16, 2009, 9:19:49 PM12/16/09
to google-analytics-api - GA Data Export API
Hey Brandt,

You are correct, if somebody arrives at 23:55, then requests another
page at 00:15, Google Analytics will split this into 2 visits.

The time is based on the timezone configured in the Google Analytics
account management interface. Default is Pacific. Also daylight
savings is applied based on the time zone configured.

Reply all
Reply to author
0 new messages