I have Analytics set up where I am also sending The User ID.This is set when a user logs in, and is undefined when not logged in.I am trying to track administrators of the site. When an admin logs into the admin section of the site a Custom Dimension is set with the scope being User.My understanding of dimensions with a user scope is that it should persist between sessions - almost like a permanent cookie.However, studying the analytic data, the Custom Dimension does not persist when the admin logs out. I would have thought that it should persist as the Analytics Client ID remains the same?Could someone please advise as to wether this is normal behaviour?If it is, what would be the appropriate method to create a dimension that would persist?
User Scope Dimension does not appear to persist between sessions
google analytics
If your User ID is user scoped, then whatever the last value was set at, will be the value applied to all hits for that user, across all sessions. If it changes in the next session, then the value, again across all hits, across all sessions, will be changed to that latest value.So what you probably shouldn't be doing is setting the value when the user logs out. Put in some logic to only define the user ID custom dimension when the User ID value is valid (ie. not logged out or undefined or whatever).