0

I have enabled userId feature in Google Analytics. On Login page i am setting userId. and also on other pages which user visits after login.
Problem:
User A logs In
User A logs out
User B logs(in same browser session)
User B logs out
User A logs in again logs( In same browser session)
User A log out


In user explorer report for above scenario in google analytics, Count of sessions for user A and B is 1 and 1 respectively.
And also, User A session duration includes the timing of user B' session duration

Expected:
user A should have 2 sessions count and user B should have one.

Do I need to do something when user logs out?

I have also tried by statrting new session explicitly when user logs in, But related custom dimensions are not set in that case. To start new session i have used this link Is it possible to manually end a Google Analytics Session?

Yasin
  • 1,150
  • 5
  • 19
  • 39

1 Answers1

0

ga('send', 'pageview', { 'sessionControl': 'end' });
Written this code on logout event. this will forcefully end session of the user and custom dimensions data is also preserved

Yasin
  • 1,150
  • 5
  • 19
  • 39