Log Out and Anonymous Users

  • 6 February 2023
  • 6 replies


Hello everyone,

I wanted to know that is there any way that if a user logs out and then perform any events, than those events should be not linked to the previous logged in user ID without changing the device ID.

I know right now the only solution is to regenerate device ID while logging out, but I wanted to mantain that device ID to know how many unique peoples are using from that device ID.


Best answer by r0bbieWa11ace 7 February 2023, 22:35

View original

6 replies

Userlevel 2
Badge +3

Hey @shailander ! This is a great question. When using our SDKs, we will always set a default Device ID that allows us to connect the event stream to a user as they interact with your product. When a user logs in on each device we are then able to connect all their engagement data together from their devices for you to have at the user level. 

I have provided a screenshot below of a document that will help add more context around this for you.

Does this help answer your question?




Hi @r0bbieWa11ace , thanks for the explanation.

But my problem statement is that, I don’t want amplitude to link non-login state events (userID is null) to the user which was logged in last on the same browser. Currently, Amplitude uses device ID to map the events to the same user based on device ID even when userID is null.

The only solution I can find is to reset the device ID when user logs out so that the events will come as new anonymous user based on the new device ID. But I want to keep track of the same device ID without linking it to last logged in user.

Is there any way we can switch the priority of filtering users from deviceID → userID to just userID, so that if userID is null, amplitude will basically link all the events after that to a new anonymous user based on the same Device ID without linking it to last logged in userID because they share the same device ID.


  1. User logs in. Device ID : abc, user ID : shailander, amplitude ID : 1
  2. User logs out, Device ID : abc, user ID : null, amplitude ID : 2 (Count as new anonymous user)
  3. Same user logs in, Device ID : abc, user ID : shailander, amplitude ID : 1
  4. User logs out again, Device ID : abc, user ID : null, amplitude ID : 2

So, we keep track of users firstly on userID, if not available, then uses device ID to create another user.

Hope I am able to clarify my problem statement. Let me know if any further clarifications is needed or if it is possible ?

PS : my goal is to not track events with userID as null to some user(having userID) sharing the same device ID, without clearing/resetting the device ID when switching from logged in state - logged out state


Userlevel 2
Badge +3

@shailander :  Is your use case where multiple users engage on a single device like a kiosk?


@r0bbieWa11ace No, it’s just I don’t want to track non-login users with last login user, even if they are the same person

Userlevel 2
Badge +3

@shailander : I would recommend one of the following options:

  • Track authentication status as a user status and so in Amplitude you can filter down to events where user’s are logged in.
  • Track each event with the user status as an event property and set up a block filter to exclude events where event property user status = not logged in.  

Either of these will allow you to have maintain the analysis you would like without add complexity to your instrumentation


@r0bbieWa11ace Thanks a lot for the help!!