Skip to main content

Update app user metadata

Once you have registered your app user, you can attach a map with key-value pairs which contain additional data about the app user and their behavior.

Update app user metadata by calling the Shake.updateUserMetadata method anywhere in your code after registering the app User.

Special keys

Values from these two keys will be presented nicely on the Shake dashboard, so we suggest you use them:

  • first_name
  • last_name

Updates

Updates to the app 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 app user metadata from one place in your code upon every app user change

UserManager.swift
class UserManager {
func didLogin(response: UserResponse) {
/// Some post log in operations
Shake.updateUserMetadata(self.userInfoDictionary())
}
func userInfoDictionary() -> Dictionary<String, Any> {
return [
"first_name": self.currentUser.firstName,
"last_name": self.currentUser.lastName,
"email": self.currentUser.email,
"status": self.currentUser.status
]
}
}

and updating specific app user metadata in their respective contexts:

UserSettingsViewModel.swift
func onUserSettingsConfigured(userSettings: UserSettings) {
fetchUserInformation()
Shake.updateUserMetadata([
"userSettings": userSettings.description
])
}

Limitations

The total map size of the app user metadata must not exceed 50 KB. The app user metadata dictionary also supports a maximum of 100 keys and doesn't allow nested dictionaries.

If any of these validations fail, the update method is dropped with the appropriate console message.

App user metadata vs. Ticket metadata

Track app User metadata to understand and describe your app User better. Examples are:

  • First and last name
  • App 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