Skip to main content

What are User Profiles?

In the first chapter when you learned to initialize the Engagespot front-end SDK, you passsed a unique identifier to the userId parameter. What if you want to specify more details about your user such as their name, email, location etc?

Engagespot allows you to add more attributes to a user's profile as key-value pairs. This helps you to use those attributes in your email provider's template or for any other purposes.

info

Some providers look for certain attributes in your user's profile inorder to send notifications. For example, FCM needs your user's profile to have a token attribute inorder to deliver push notification to them. Make sure you set the required profile attributes in your user profile.

Adding attributes to user's profile.

You can add attributes as key-value pairs to your user's profile either via REST API or our client SDKs (For example - ReactJS or Core Javascript).

Using Javascript Core SDK

You should use the setProfileAttributes method to store key value pairs to your user's profile

const engagespotClient = new Engagespot('API_KEY', {
userId: '123e4567-e89b-12d3-a456-426614174000',
});

engagespotClient.setProfileAttributes({
email: '[email protected]',
phone: '+19876543210',
name: 'Anand',
});

This will add three profile attributes - email, phone and name to your user's (123e4567-e89b-12d3-a456-426614174000) profile.

Using REST API

You should use the PUT method of /profile endpoint in the REST API to update your user's profile. Read API Docs for more information.

PUT https://api.engagespot.co/v3/profile

var axios = require('axios');

axios.put(
'https://api.engagespot.co/v3/profile',
{
full_name: 'Rose DeWitt-Bukater',
email: '[email protected]',
gender: 'Female',
hometown: 'Pennsylvania',
},
{
headers: {
'X-ENGAGESPOT-API-KEY': 'YOUR_ENGAGESPOT_API_KEY',
'X-ENGAGESPOT-USER-ID': 'YOUR_USER_UNIQUE_ID',
'Content-Type': 'application/json',
},
}
);
info

Alternatively, you can use PATCH method which uses JSON Patch syntax to do complex operations on your Profile object.