getUserId
The getUserId() method returns the current user ID.
Syntax
getUserId()
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
Returns
The user ID value.
Format: Example: ABC123
Type: string
Examples
To return a user ID:
_paq.push([
function () {
console.log(this.getUserId());
},
]);
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
getUserId(): Promise<string>
A sample of the return value:
Notes
- It's a good practice to remove the user ID value after the user logs out. This helps to correctly track sessions for other users who may use the same device.
- When a page doesn't reload after a user logs out, it's even more important to remove their user ID.
Related methods
Updated 6 days ago