User segmentation

Through the SDK’s User class, we allow you to send us data related to the user. After being sent to our servers, the data is analyzed and used at a later time when serving campaigns.

The User class is extending the HashMap<String, Object> and implements getters and setters which are allowing you to get and provide the following data, respectively:

Property Type Description
iap Boolean Has the user done any in-app purchase
iap_amount Float The amount of money that the user has spent on IAP
number_of_sessions Integer The number of sessions that the user had started
ps_time Long The date when the account was created
last_session Long The date of the last session
age Integer Age of the user
gender UserGender Gender of the user
interests String[] List of interests of the user
connection UserConnectionType The connection type used by the user
device String The device used by the user
app_version String The version of the app that is currently executed
custom parameters Object The custom parameters that could be set

Predefined parameters

Fyber’s SDK supports predefined values for the following parameters: gender and connection type. Predefined values are supported as enumerators.

Enumerator Constants
UserGender male
  female
  other
UserConnectionType wifi
  3g

Add custom value

Regarding the custom values, we are providing the addCustomValue(String key, Object value) method. The value that you have provided as a parameter on this method will be set in the HashMap, as long as the provided key doesn’t match with any of the reserved ones. Reserved keys are presented on the Property column on the table above.

Add custom value

Regarding the custom values, we are providing the setCustomParameters method. The value that you have provided as a parameter on this method will be set in the map, as long as the provided key doesn’t match with any of the reserved ones.

Available data types are:

Data type Description Example
int whole numbers "123"
float number with decimal point "123.4"
boolean true/false "true"
daterange Date expressed as Unix time. On Android you can get the value using the getTime() property of Date, divided by 1000 "1423958400" for 15/02/2015
string any string input "foobar"

Note: All values should be sent as a string, as the conversion to a specific data type happens on the server.

Code example

The following example shows how to use the User and provide informations about the user to the Fyber SDK.

// Assuming user data is available in a MyUser object
MyUser u = getCurrentUser(); // user that has 5 sessions and has not done any in-app purchase

// Retrieve a User attribute, i.e IAP amount:
boolean iap = User.getIAP();

// Set properties of the User
User.setNumberOfSessions(u.getSessions()) // 5 sessions
User.setIAP(u.hasDoneIAP()); // false (no IAP)

// Update values if something has changed (e.g. user has completed an in-app purchase)
User.setIAP(u.hasDoneIAP()); // true (user has done an IAP)

// Set custom parameters
User.addCustomValue("level", u.getCurrentLevel());