Use this API to reset a user’s identity to an anonymous state after they have logged out. See Using Identify for use cases when managing identity across browsers and devices.
heap.resetIdentity()
resets a user's identity to a random anonymous user ID. A new session for anonymous user will begin when called if the user was previously identified. The method has no effect if the user was previously anonymous when called.
This method should be used typically when a user logs out of an application on a device that might be shared with others who use the application, or when your application has the concept of a user switch applied (Jane is now using the application instead of John, this is common for support teams who log in or "masquerade" as their customers). The event data from the client after heap.resetIdentity()
is called will be associated with an anonymous user and the next identity
value provided via heap.identify
if it is called later.
Note that calling this method disassociates the user from any user properties set with addUserProperties()
.
// resetIdentity should be called when a user logs out of an application.
heap.resetIdentity();
// resetIdentity should be called when a user logs out of an application.
heap.resetIdentity();
// resetIdentity should be called when a user logs out of an application.
[Heap resetIdentity]
// resetIdentity should be called when a user logs out of an application.
Heap.resetIdentity()
// resetIdentity should be called when a user logs out of an application.
Heap.resetIdentity()
// resetIdentity should be called when a user logs out of an application.
Heap.resetIdentity()
Update Your Heap Snippet
To take advantage of
resetIdentity()
you must make sure your snippet matches the version in our installation instructions. Please reach out to [email protected] with any questions!