Audience
The audience of your product are all users who interact with it. The LMG SDK uses a very flexible style of identifying and tracking users to support any number of use cases and login systems.
There are 3 states a user can be in:
- Anonymous - ie. anonymous
- Identified - Associated with a unique user id, but not verified
- Verified - Associated with a unique user id, and verified via a signed token
Anonymous Usage
When the SDK is first initialized, a unique session is generated. This is an anonymous identifier for the current user that lasts for the lifecycle of the app usage. If you do not have login functionality or want to have fully anonymous usage, you don't need to proceed.
Identifying Users
Identifying users registers all the app activity with a particular user id. This is generally the unique id you use to identify the user in your auth system.
You identify a user by calling:
[[LMGClient shared] identify:@"UNIQUE_USER_ID" traits:nil completion:^(LMGUser * _Nullable user, NSError * _Nullable error) {
... your code goes here ...
}];
It's possible to identify users and enable features that require identification without having logins. For example, a device advertiser ID could be used as the user id to your identify
calls.
Verifying Users
A verified user is considered to be "logged in". Users are verified by setting a signed token before calling identify
:
[[LMGClient shared] setUserHash:@"HMAC_TOKEN"];
[[LMGClient shared] identify:@"UNIQUE_USER_ID" traits:nil completion:^(LMGUser * _Nullable user, NSError * _Nullable error) {
... your code goes here ...
}];
The HMAC token is generated based on the Audience Identification Secret key that is unique to your property. It allows the GetintheLoop Platform to trust that this user is actually authenticated.
For details and an example implementation, see our Users, Audience, & Identification Guide.
Resetting Identification
[[LMGClient shared] logout:^(LMGSession * _Nullable session, NSError * _Nullable error) {
... your code goes here ...
}];
Updating Profiles
You can send any user profile data you like to the GetintheLoop Platform via profile traits. There are standard user attributes that have defined values and are common to all users, and custom user attributes that are unique to your app.
Profile traits are used to generate automatic demographic reports and interest profiles. They can also be used to build custom Audience segments and add relevance to Collections, search, and other platform features.
Standard Traits
The complete list of standard user attributes that can be updated are described in the LMGUserTraits
object. Standard user attributes such as a user's name or email address can be updated by calling:
LMGUserTraits *traits = [LMGUserTraits new];
traits.name = @"John Doe";
traits.gender = LMGUserGenderMale;
traits.birthday = [NSDate new];
traits.email = @"john.doe@email.com";
[[LMGClient shared] identify:@"UNIQUE_USER_ID" traits:traits completion:^(LMGUser * _Nullable user, NSError * _Nullable error) {
... your code goes here ...
}];
Custom Traits
Typically our customers see a lot of value in sending custom data that relates to customer development, such as price plan, value of purchases, etc. Custom user attributes can be created and modified by setting the customTraits
on the LMGUserTraits
object with a dictionary.
LMGUserTraits *traits = [LMGUserTraits new];
traits.customTraits = @{
@"paid_subscriber" : @YES,
@"monthly_spend" : @155.5,
@"team_mates" : @3
};
[[LMGClient shared] updateUser:traits completion:^(LMGUser * _Nullable user, NSError * _Nullable error) {
... your code goes here ...
}]
Additional Configuration
Setting Authentication Requirements
You can define the minimum authentication needed to redeem an offer. This authentication level is set in the SDK configuration.
If this auth requirement is not met, the SDK will notify you that an authentication is needed.
This is done through LMGClient
authentication delegate LMGClientAuthenticationDelegate
's method: userAuthenticationRequiredByClient:
.
You should set an authentication delegate and implement this method to present an authentication flow and identify/verify the user.
i.e.:
@import LMGData;
@interface AppDelegate() <LMGClientAuthenticationDelegate>
@end
@implementation AppDelegate
- (void)userAuthenticationRequiredByClient:(LMGClient *)client {
... your authentication flow and user identification/verification goes here ...
}
@end