Skip to main content

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.user.identify(
"UNIQUE_USER_ID"
)

Verifying Users

A verified user is considered to be "logged in". Users are verified by setting a signed token before calling identify:

lmgClient.user.identify(
"UNIQUE_USER_ID",
"HMAC_TOKEN"
}
)

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.

All other methods will wait for the identification to complete.

eg:

lmgClient.user.identify(
'UNIQUE_USER_ID',
{
hmac: "HMAC_TOKEN"
}
);
lmgClient.business.list({ limitToSaved: true }); // waits for identify, then returns user's bookmarked Offers

Resetting Authentication

User profile status must be cleared when a user logs out in your application.

lmgClient.user.resetSession();

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

All user attributes and traits can sent during the identify process:

lmgClient.user.identify(
"UNIQUE_USER_ID",
{
hmac: "HMAC_TOKEN",
profile: { // Profile -- all keys are optional
email: "email@ddre.ss"
name: "User Name"
birthday: new Date('1968-04-03'),
gender: lmgClient.user.genders.Male // .Male, .Female, .Other, .PreferNotToSay
}
}
)

You can also update traits after the user has been identified with the same call.

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.

The Profile argument of lmgClient.user.identify also accepts a traits dictionary:

lmgClient.identify(
"UNIQUE_USER_ID",
{
hmac: "HMAC_TOKEN",
profile: { // Profile -- all keys are optional
email: "email@ddre.ss"
name: "User Name"
birthday: new Date('1968-04-03'),
gender: lmgClient.user.genders.Male,
traits: {
paid_subscriber: true,
monthly_spend: 155.5,
account_tier, "gold"
}
}
}
)