Updating the User Profile reflects the most recent information about a user. User Profile data enables you to:
- Populate any Iterable channel (Email, Inapp, Push, SMS, etc..) with personalized information later with Handlebars
- Flag users for A/B testing, cohorting and Segmentation
- Start a user journey
A user profile value can be a value like first name, or a dynamic value that changes, such as the date of last login or the number of times the user purchases a food.
Table of contents
NOTES
- You can store a soft limit of 1,000 user parameters on your user profiles. If you feel you may go over this, please reach out to your Iterable point of contact and request it to be raised.
- Again, if you are only identifying the user on the
IterableAPI.userId
call, then Iterable assumes you do not know the email of the user yet and will create a placeholder email calleduserId+hashValue@placeholder.email
. We will discuss in the next section how we can update the email of an unkown user.
How to make the updateUser call
Iterable can handle multi-level deep nested objects. You will want to add
that object to the dataField
arguement in the IterableAPI.updateUser()
user call.
Swift
// The IterableAPI.updateUser() can be added any method within your code. myFunc() is just an example myFunc(){ // Example data fields let dataField : [String: Any] = [ "Address":[ "Street1": "123 Main St", "Street2": "Apt 1", "City": "Iter-a-ville", "State": "Ca", "Zip": "90210" ] ] // Most important code IterableAPI.updateUser(dataField, mergeNestedObjects: false, onSuccess: myUserUpdateSuccessHandler, onFailure: myUserUpdateFailureHandler) } func myUserUpdateSuccessHandler(data:[AnyHashable:Any]?) -> () { // success print("sent to Iterable success") } func myUserUpdateFailureHandler(reason:String?, data:Data?) -> () { // failure print("sent to Iterable failure") }
Java
JSONObject address = new JSONObject(); JSONObject datafields = new JSONObject(); try { address.put("Street1", "123 Main St"); address.put("Street2", "Apt 1"); address.put("City", "Iter-a-ville"); address.put("State", "CA"); address.put("Zip", "90210"); datafields.put("dataFields", address); } catch (JSONException e) { e.printStackTrace(); } IterableApi.getInstance().updateUser(datafields);
Now you will be able to personalize the user's City (or any user profile) later with Handlebars in any of your channels by writing this code within the Iterable platform:
NOTES
-
mergeNestedObjects
default is set tofalse
-
mergeNestedObjects
set totrue
means that if the user profile has data:{mySettings:{mobile:true}}
and your code changes the contact field to:{mySettings:{email:true}}
, the resulting profile will be:{mySettings:{mobile:true,email:true}}
and merge the two results.
When to make the updateUser call
Typically you want to make the updateUser()
call when:
- Your user has changed or added their personal information
- Completed a key step in your onboarding, sales or retargeting process. For
example, you may want to add
"completedOnboarding":true
or"testGroup":"A"
to the user profile for later segmentation, splitting the users down different journeys or analyzing later for test comparisons.
Tracking anonymous users
Iterable can track anonymous users by utilizing the userId
. This will
automatically create a placeholder email. You can use a variety of client
side libraries to generate a unique ID on demand and pass it to the Iterable
userId
parameter.
Taking a user from anonymous to known
Iterable can handle anonymous to known users. The function below will update the current user email and userId. You will likely want to call the code below when your user logs in or identifies themselve via a signup.
Swift
// The IterableAPI.updateUser() can be added any method within your code. yourUserIsNowKnownFunction() is just an example let email = "the_new_email_of_the_user@email.com" //Call yourUserIsNowKnownFunction() { IterableAPI.updateEmail(email, onSuccess: myUserUpdateSuccessHandler, onFailure: myUserUpdateFailureHandler) } func myUserUpdateSuccessHandler(data:[AnyHashable:Any]?) -> () { // success print("sent to Iterable success") } func myUserUpdateFailureHandler(reason:String?, data:Data?) -> () { // failure print("sent to Iterable failure") IterableAPI.email = email //This assumes your saving your user profile fields in the datafield object locally IterableAPI.updateUser(dataField, mergeNestedObjects: false) }
Java
final String email = "the_new_email_of_the_user@email.com"; IterableApi.getInstance().updateEmail(email, new IterableHelper.SuccessHandler() { @Override public void onSuccess(JSONObject data) { System.out.println("sent to Iterable success"); } }, new IterableHelper.FailureHandler() { @Override public void onFailure(String reason, JSONObject data) { System.out.println("sent to Iterable failure"); IterableApi.getInstance().setEmail(email); //This assumes your saving your user profile fields in the datafield object locally IterableApi.getInstance().updateUser(datafields); } });
There is a chance the updateEmail()
call will fail. The most likely reason
is that the user already exists so we should now update the user call
directly in the onFailure
handler.
Comments
0 comments
Article is closed for comments.