Managing customer profiles

The Medio Platform allows you to include information about your users in an individualized profile called a Common Customer Profile (CCP). You can include information such as date of birth, gender, and other user preference settings to see reports on user profiles and to target users with relevant content, even across different devices and applications. The SDK provides APIs to easily manage attributes in these profiles.

Setting a user ID

If your application has a unique ID for each user such as a numeric ID or username, then we recommend that you set each user’s ID to ensure the most accurate reporting. Setting a user ID also ensures that your users receive the most relevant content if your application requests content from Medio. You can set a user’s unique ID by setting the userId property with the setUserId: selector:

[MEDIOEVENT setUserId:@"user1234"];

We recommend that you hash your user IDs before setting them if they contain any personally identifiable information. If you don’t set a user ID then we’ll use an automatically generated anonymousId in combination with other factors to identify that user.

Setting single-valued attributes

Let’s say that your application has a preferences view that allows users to set their favorite color. You can set the selected color in a “favoriteColor” attribute using the setUserAttributeValue:forKey: selector:

[MEDIOEVENT setUserAttributeValue:@"green" forKey:@"favoriteColor"];

Setting multi-valued attributes

You can also set attributes that contain a list of multiple values. For example, if you allow your users to specify multiple favorite colors as a preference, use the setUserAttributeValues:forKey selector and pass in an array of values for a “favoriteColors” attribute:

[MEDIOEVENT setUserAttributeValues:@[@"green", @"blue", @"orange"] forKey:@"favoriteColors"];

Note that the SDK updates multi-valued attributes by replacing all values with the last specified values. For example:

[MEDIOEVENT setUserAttributeValues:@[@"green", @"blue", @"orange"] forKey:@"favoriteColors"];
// favoriteColors contains the values ["green", "blue", "orange"]

[MEDIOEVENT setUserAttributeValues:@[@"red", @"yellow"] forKey:@"favoriteColors"];
// favoriteColors now contains the values ["red", "yellow"]

Setting gender

Use the constant kUserAttributeGenderKey as the attribute name when setting a user’s gender and use the constants kUserAttributeGenderValue_Male or kUserAttributeGenderValue_Female when specifying male or female values. For example, you can set the user’s gender to female using the following code:

[MEDIOEVENT setUserAttributeValue:kUserAttributeGenderValue_Female forKey:kUserAttributeGenderKey];

Setting date of birth

Use the constant kUserAttributeDateOfBirthKey as the attribute name with the setUserAttributeYear:year:month:day:forKey selector when setting a user’s date of birth. For example, you can set the user’s date of birth to January 1, 1980 using the following code:

[MEDIOEVENT setUserAttributeYear:1980 month:1 day:1 forKey:kUserAttributeDateOfBirthKey]; 

Removing attributes

You can remove attributes from a user’s profile using the removeUserAttributeForKey: selector. For example, you can remove the “favoriteColor” attribute from a user’s profile using the following code:

[MEDIOEVENT removeUserAttributeForKey:@"favoriteColor"];

The removeUserAttributeForKey: selector removes both single-valued and multi-valued attributes from a user’s profile.