Update User

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:

FieldTypeDescription
propertiesObjectA JSON object containing properties to add to the current user
settings optionalObjectSettings 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.

PropertyTypeDescription
first_nameStringThe first name of the user.
last_nameStringThe last name of the user.
nameStringThe 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.
emailStringThe email address of the user.
user_idStringA unique identifier for the user.
signed_up_atISO-8601 Timestamp StringThe date at which a person signed up.
contactsArray of objectsOne 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:

ObjecdtDescription
onCompleteThis 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.
onSuccessThis 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!'); }
   }
  );