Update user metadata
Once you have registered your app user, you can attach a map with key-value pairs which contain additional data about the user and their behavior.
Update user metadata by calling the Shake.updateUserMetadata
method anywhere in your code
after registering the User.
Special keys
Values from these three keys will be presented nicely on the Shake dashboard, so we suggest you use them:
first_name
last_name
end_user_id
Updates
Updates to the user metadata are merged. This allows you to update user metadata in segments from various parts of your app, even when offline.
A common approach developers take is updating generic user metadata from one place in your code upon every user change
const onLoggedIn = (user) => {const metadata = {first_name: user.firstName,last_name: user.lastName,email: user.email,status: user.status};Shake.updateUserMetadata(metadata);}
and updating specific user metadata in their respective contexts:
const onUserSettingsConfigured = (userSettings) => {fetchUserInformation();const metadata = {userSettings: userSettings.toString()};Shake.updateUserMetadata(metadata);}
Limitations
The total map size of the user metadata must not exceed 50 KB. If this validation fails, the update method is dropped with the appropriate console message.
User metadata vs. Ticket metadata
Track User metadata to understand and describe your User better. Examples are:
- First and last name
- User ID
- Address
- Subscription status
- Date of birth
Use Ticket metadata to attach useful custom data to each ticket. Examples are statuses of various app variables at the moment the ticket is sent:
- Current chat room ID
- List of items currently in a shopping cart
- Task synced true/false
- Number of search results
- List sorted by what
- Video muted true/false