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}

Sending user information allows you to associate a user to their user profile and activities or actions in your app. The user's actions and attributes can also tracked across devices and platforms by using the same userId.

Some scenarios for identifying a user and their associated app activities are:

  • When a user completes app sign up
  • When a user completes sign in process
  • When a user launches your app
  • When a user modifies or updates their user profile