Learn how to collect profile data in a mobile app.
You can use the Profile extension to store attributes about your user on the client. This information can be used later to target and personalize messages during online or offline scenarios, without having to connect to a server for optimal performance. The Profile extension manages the Client-Side Operation Profile (CSOP), provides a way to react to APIs, updates user profile attributes, and shares the user profile attributes with the rest of the system as a generated event.
The Profile data is used by other extensions to perform profile-related actions. An example is the Rules Engine extension that consumes the profile data and runs rules based on the profile data. Learn more about the Profile extension in the documentation
The Profile functionality described in this lesson is separate from the Real-Time Customer Profile functionality in Adobe Experience Platform and Platform-based applications.
Successfully built and run app with SDKs installed and configured.
Imported the Profile SDK.
import AEPUserProfile
In this lesson, you will:
It would be helpful for targeting and/or personalization to quickly know if a user has made purchase in the app before. Let’s set that up in the Luma app.
Navigate to Cart.swift
Add the below code to the processOrder()
function.
var profileMap = [String: Any]()
profileMap["isPaidUser"] = "yes"
UserProfile.updateUserAttributes(attributeDict: profileMap)
The personalization team might also want to target based on the user’s loyalty level. Let’s set that up in the Luma app.
Navigate to Account.swift
Add the below code to the showUserInfo()
function.
var profileMap = [String: Any]()
profileMap["loyaltyLevel"] = loyaltyLevel
UserProfile.updateUserAttributes(attributeDict: profileMap)
Additional updateUserAttributes
documentation can be found here.
Once you have updated a user’s attribute, it will be available to other Adobe SDKs but you can also retrieve attributes explicitly.
UserProfile.getUserAttributes(attributeNames: ["isPaidUser","loyaltyLevel"]){
attributes, error in
print("Profile: getUserAttributes: ",attributes as Any)
}
Additional getUserAttributes
documentation can be found here.
loyaltyLevel
is set.profileMap
value.Next: Map data to Adobe Analytics
Thank you for investing your time in learning about Adobe Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, please share them on this Experience League Community discussion post