Identifying Users and Creating a User (For Automation Service)
To identify the user currently interacting with your website and allow Metrix servers to associate received actions with that user, you must call the following method before any other methods.
This method creates a User on Metrix servers, which can be viewed in the User Lookup section of the Metrix dashboard.
authorizeUser(customUserId: string) : void| Name | Type | Description | Required |
|---|---|---|---|
| customUserId | string | A unique identifier assigned to the user on your website — for example, a username or any other unique ID. | Yes |
To revert the user to an anonymous state during logout, call:
deauthorizeUser() : voidUpdating User Information (For Automation Service)
After calling authorizeUser, you can update the User’s information in User Lookup using the following methods:
setFirstName(firstName: string) : voidsetLastName(lastName: string) : voidsetEmail(email: string) : voidsetHashedEmail(hashedEmail: string) : voidsetPhoneNumber(phoneNumber: string) : voidsetHashedPhoneNumber(hashedPhoneNumber: string) : voidsetCountry(country: string) : voidsetCity(city: string) : voidsetRegion(region: string) : voidsetLocality(locality: string) : voidsetGender(gender: string) : voidsetBirthday(birthday: string) : voidsetCustomAttribute(key: string, value: string) : voidRetrieving the User ID (Optional)
For each user identified by a customUserId, Metrix generates a unique automationUserId on its servers.
This ID becomes available immediately after the user is created and can be retrieved using:
onAutomationUserIdReceived().then((automationUserId: string) => {
// todo
});In most cases, you do not not need to manually retrieve or store the automationUserId, unless you have a specific use case that requires it.