Updates properties on the existing user
These operations provide you with the ability to manage the current user's data. The operations allow for additional user properties to be uploaded to ZetaHub or changed from their current values.
User Updates are blocking JavaScript calls.
bt('updateUser', properties, settings={});
The updateUser
call has the following fields:
Field | Type | Description |
---|---|---|
properties | Object | A JSON object containing properties to add to the current user |
settings optional | Object | Settings specific to this event. Currently supports specification of onComplete , onSuccess , and onFailure callback functions. See Settings below for more information. |
Properties
While any JSON data can be supplied as user properties, a few properties are standardized and specially handled by Zeta's systems.
Property | Type | Description |
---|---|---|
first_name | String | The first name of the user. |
last_name | String | The last name of the user. |
name | String | The full name of the user. Note that unless a user has this property set, the user's name will appear in ZetaHub as a concatenation of their first_name and last_name . |
email | String | The email address of the user. |
user_id | String | A unique identifier for the user. |
signed_up_at | ISO-8601 Timestamp String | The date at which a person signed up. |
contacts | Array of objects | One or more contacts for this user. Each contact should be a hash/object with type and value attributes. A status is optional and defaults to "new". The type can be either "email" or "phone". If the type is an "email", it should satisfy standard email format validations. If the type is "phone", it should be sent in the ISO E.164 format with the "+" symbol followed by the country code and then the number. The status attribute can be used to unsubscribe the contact by sending its value as "inactive" or made active by sending its value as "active".If a contact with the given type and value already exists for this user, it will be overwritten with the provided values. Otherwise, it will be added for this user. |
Settings
The settings
object is used for configuring the updateUser
call.
Three settings
objects are currently allowed for updateUser calls using the p13n.js
library:
Objecdt | Description |
---|---|
onComplete | This setting allows the caller to specify a callback function once the updateUser function has completed. The function will be called regardless of whether the update to the user was successful or not. The function should have no parameters (nothing will be passed to it). |
onFailure(error) | This setting allows the caller to specify a callback function if the updateUser function has completed with an error. The error raised by the updateUser function will be passed into this callback. |
onSuccess | This setting allows the caller to specify a callback function once the updateUser function has completed successfully. The function should have no parameters (nothing will be passed to it). |
bt('updateUser',
{user_id: 'abcde123'},
{onComplete: function()
{ console.log('User Update Completed!'); }
}
);
bt('updateUser',
{user_id: 'abcde123'},
{onFailure: function(err)
{ console.log('Update completed with error: ' + err); }
}
);
bt('updateUser',
{user_id: 'abcde123'},
{onSuccess: function()
{ console.log('Update completed successfully!'); }
}
);