Chris
Chris

Reputation: 2374

Google Analytics end session when page reloads

We use Google analytics for tracking in our webapp. When we update the document.location, does this automatically ends the Google analytics session?

When the user is idling for 30 seconds, we want to bring him to the start page again with:

location.reload();

Upvotes: 1

Views: 3535

Answers (1)

Brian Norman
Brian Norman

Reputation: 564

Calling location.reload() acts the same as clicking the refresh button in your browser. Since it is not resetting the GA cookie, the GA session will not end. By default, the GA session expires after 30 minutes of inactivity. See https://support.google.com/analytics/answer/2731565?hl=en.

It is important to note that refreshing the page will be recognized as activity by GA. If you are refreshing the page after 30 seconds of inactivity, the session will never expire assuming that the user never leaves the page.

If you would like to manually control when a GA session is started and ended, see https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#session.

Upvotes: 2

Related Questions