Page updated Jan 19, 2024

Identify user

This API sends information about the current user to Amazon Pinpoint.

Additional information such as the user's name, email, location, and device can be included by specifying the UserProfile. Custom attributes can also be included by setting UserProfile.customProperties.

If the user was signed in through signIn you can retrieve the current user's ID as shown below:

1import { identifyUser } from 'aws-amplify/analytics';
2import { getCurrentUser } from 'aws-amplify/auth';
3
4const location = {
5 latitude: 47.606209,
6 longitude: -122.332069,
7 postalCode: '98122',
8 city: 'Seattle',
9 region: 'WA',
10 country: 'USA'
11};
12
13const customProperties = {
14 plan: ['plan'],
15 phoneNumber: ['+11234567890'],
16 age: ['25']
17};
18
19const userProfile = {
20 location,
21 name: 'username',
22 email: 'name@example.com',
23 customProperties
24};
25
26async function sendUserData() {
27 const user = await getCurrentUser();
28
29 identifyUser({
30 userId: user.userId,
31 userProfile
32 });
33}