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?
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
Related
I want to check whether any google/gmail account is logged in current session. if not just redirect to the log in page, else retrieve the gmail id. is their any posibility to do like this?
Updates
Using Google api v3 to connect with the calendar; am not able to creating connection if another google account is logged in in current session; so i need to check whether any google account is logged in the current session;if yes get the gmail id; if not then it will work fine
I want to optimize a kind of page that prompts the user to either login if the user already has an account or register otherwise.
I have setup events for when the user arrives to the page, clicks on one of several possible login buttons (username and password, Facebook account, Google account, etc) or clicks on the register button.
To measure the conversion I would like to see from all of those that arrive to the page but did not click the login buttons, what is the conversion rate of those that register.
Basically I need to measure Registered / (Landed - Logged in).
Is there a way to measure this with Google Analytics or do you recommend some other solution?
I have 2 custom variables in Google Analytics with scope set to 2(Session).
One variable tracks user role and other tracks user Program.
Our site works in a way that there would be a single role for different programs.
So a user can login with different roles.
If different users login in the same browser the custom variables values are overwritten.
For example the user logs in where role is 'Admin' and Program is 'ABC'.
The Google Analytics would show report
'Admin' 'ABC'
If the user logs off and logs in without closing the browser with role as 'Admin' program 'DEF' , the Analytics would now show report as
'Admin' 'DEF'. Thus 'ABC' gets replaced.
This does not happen if the user closes the browser and logs in again.
If user closes the browser and logs in again, I get report like
'Admin' 'ABC'
'Admin' 'DEF'
Is there a way to prevent overwriting even if the user does not close the browser?
The code is like:
_gaq.push(['_setCustomVar', 1, 'User Role', applicationRoleName, 2]); <br>
_gaq.push(['_setCustomVar', 3, 'Program Name', applicationProgramCode, 2]);
This is expected behavior. If the user logs out of your application and logs in again he is still in the same google analytics session. If he closes the browser he starts a new session, so you get two data sets with different values, one for each session.
So in effect you are asking "can I programmatically start a new tracking session in Google Analytics" to which to my best knowledge the anwser is no (at least not with methods provided by Google, of course you could change the Google cookie manually).
You might try to set setSessionCookieTimeout() to 100 milliseconds (or another ridiculously small value) specifically on your logout page so that sessions expire on logout immediately (and set it back to 0 - which means "session ends on browser close - on the following pages). However this is untested, not approved by Google, will change the way your data is collected and I would not recommend it.
Also my comment on the forced migration to universal analytics still applies.
A slightly odd question came through to us. Is there way to programatically cause a single user to be 'logged out' when logged in as another user (e.g. as an administrator).
e.g. An admin on stackoverflow would decide that I should be logged out - click a button and then I would be forced to log in again on my next SO request.
This is for a site using standard forms based authentication running ASP.net.
Because the authenticated sessions depend on the cookie, they don't know about each other.
So you need to track the logged in users may be along with their roles. And perform a check at the beginning of every request.
You start by tracking:
user A - role 'admin' logs in. Create a row in db
user A - role 'manager' logs in, now you mark the row in step 1 as expired, and create a new row for user A - role 'manager'
user A - role 'admin' attempts to perform some action. In the begin request method, you will verify if this session is marked for expiration. If it is simply logout, remove the row in step 1 and redirect to login.
user A clicks logout, remove user A - role 'manager' row
I'm building a web application: some pages will be accessible by non logged-in users (demo and sign-up pages) and others will only be accessible by logged-in users (actual application). In the global.asax file, I'm currently handling the session start event by loading some variable from a query that's based on the UserID. What will happen when a non-logged in user looks at a page? I guess my question is really about how to handle the session start event when it's a logged-in user, when it's not and when a user logs in. I want a certain number of queries to run only once per session, after the user logged in.
Thanks.
I would suggest to implement Forms-Based Authentication, instead of to handle authentication via session. An example can be obtained from here:
http://support.microsoft.com/kb/301240
Don't confuse "login session" with "session state". Session state has nothing to do with whether the user is logged in.
If you want some queries run when the user logs in, you should run them when the user logs in, not in Session_Start.