User profiles

Concept: User profiles

First visit

embet.init returns a profile when no token is supplied. Persist accessToken on your user record.

const profile = await embet.init({ clientId: 'YOUR_CLIENT_ID' });
await saveTokenToUserProfile(profile.access_token);

Returning user

Pass the saved token so the SDK restores the same profile (see MAU notes on the concept page).

const savedAccessToken = await loadTokenFromUserProfile();

await embet.init({
  clientId: 'YOUR_CLIENT_ID',
  accessToken: savedAccessToken,
});

After init

const profile = embet.userProfile;

await embet.updateUserProfile({
  accessToken: profile.access_token,
  options: {
    nickname: 'Player 1',
    custom_data: JSON.stringify({ country: 'AT' }),
  },
});

Pair profile custom_data with Segmentation when you target content in the CMS.