A user attribute is any piece of data you would use to characterize on that user as you build their profile in Leanplum. User attributes, since they set to characterize your user will carry over from session to session. This is different from event parameters, which may take on different values per event and from session to session.
Uses In Leanplum
User Attributes on the Leanplum platform have many uses and are really powerful in creating meaningful engagements with your users. The main uses include:
- Personalizing content: You are able to insert user attribute values in Leanplum variables, messages, resources, and interfaces. Allowing you to personalize and reach different types of users in personal and meaningful ways.
- Segmentation Targeting: With user attributes you are also able to build audiences and different segment of users you can use in A/B testing, Messages and Campaigns
- Filtering and Grouping reports: Group and filter analytics reports by different user attributes and values. This allows you to create a histogram of average session length by number of friends or look at user data for "whales" (targeting your largest spender)
Examples:
Standard examples of User Attributes that have been tracked in the past are below. Additionally, you can see how you can set user attributes from a client level with our SDKs
- Gender
- Age
- Number of friends
- User interests
- Email ( which is a required field if you are running email campaigns)
// Passing attributes at session start allows us to target content based on the attributes.
Leanplum.start(attributes: ["gender":"Female", "age": 29])
// You can also pass them later on in the session, but you won't be able to
// target variables or messages at these for that session.
Leanplum.setUserAttributes(["gender":"Female", "age": 29])
// Clear an attribute.
Leanplum.start(userAttributes: ["gender":NSNull()])
// To allow targeting the user in email campaigns, set the "email" attribute
Leanplum.setUserAttributes(["email":"[email protected]"])
// Passing attributes at session start allows us to target content based on the attributes.
[Leanplum startWithUserAttributes:@{@"gender": @"Female", @"age": @29}];
// You can also pass them later on in the session, but you won't be able to
// target variables or messages at these for that session.
[Leanplum setUserAttributes:@{@"gender": @"Female", @"age": @29}];
// Clear an attribute.
[Leanplum startWithUserAttributes:@{@"gender": [NSNull null]}];
// To allow targeting the user in email campaigns, set the "email" attribute
[Leanplum setUserAttributes:@{@"email": @"[email protected]"}];
// Passing attributes at session start allows us to target content based on the attributes.
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("gender", "Female");
attributes.put("age", 29);
Leanplum.start(this, attributes);
// You can also pass them later on in the session, but you won't be able to
// target variables or messages at these for that session.
Leanplum.setUserAttributes(attributes);
// Clear the attributes.
attributes.put("gender", null);
attributes.put("age", null);
Leanplum.setUserAttributes(attributes);
// To allow targeting the user in email campaigns, set the "email" attribute
attributes.put("email", "[email protected]");
Leanplum.setUserAttributes(attributes);
// Passing attributes at session start allows us to target content based on the attributes.
Dictionary<string, object> attributes = new Dictionary<string, object>();
attributes.Add("gender", "Female");
attributes.Add("age", 29);
Leanplum.Start(attributes);
// You can also pass them later on in the session, but you won't be able to
// target variables or messages at these for that session.
Leanplum.SetUserAttributes(attributes);
// Clear the attributes.
attributes.Add("gender", null);
attributes.Add("age", null);
Leanplum.SetUserAttributes(attributes);
// To allow targeting the user in email campaigns, set the "email" attribute
attributes.Add("email", "[email protected]");
Leanplum.SetUserAttributes(attributes);
// Passing attributes at session start allows us to target content based on the attributes.
var attributes = {'gender': 'Female', 'age': 29};
Leanplum.start(attributes);
// You can also pass them later on in the session, but you won't be able to
// target variables or messages at these for that session.
Leanplum.setUserAttributes(attributes);
// Clear the attributes.
Leanplum.setUserAttributes({'gender': null, 'age': null});
// To allow targeting the user in email campaigns, set the "email" attribute
Leanplum.setUserAttributes({'email': '[email protected]'})
Leanplum.setUserAttributes({'gender': 'Female'});
// Examples
var attributes = {'gender': 'Female', 'age': 29};
Leanplum.setUserAttributes(attributes);
// Clear the attributes
Leanplum.setUserAttributes({'gender': 'Male', 'age': 30});
// To allow targeting the user in email campaigns, set "email" attribute
Leanplum.setUserAttributes({'email': '[email protected]'})
Constraints:
While user attributes are a powerful tool for creating meaningful engagement, there is are constraints around numbers and types you can send. See those below:
- Up to 200 unique attributes can be defined per Leanplum app.
- Attribute names must be strings, and values must be strings or numbers.
- Attribute values will be the same across all events and states in a particular session.
Additional Notes
User attribute as list
Since user attribute values can only be strings or numbers, saving an array/list will need to be converted to a string first. This will allow you to:
- Add/remove elements through our setUserAttributes API, using userAttributeValuesToAdd and userAttributeValuesToRemove
- Loop through or use specific array elements with our Templating Language
User attribute as timestamp
Leanplum supports date time segmentation on user attributes. Supported formats can be found here .
To schedule campaigns based on a user attribute timestamp, please see this article.
User attributes and case sensitivity
Please be aware that user attributes names are case-sensitive, while the values are not. For example the user attribute "language" and "Language" are considered different, while their values - "english", "English", "ENGLISH" are considered the same.