Page updated Nov 14, 2023

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.attributes.

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

import { identifyUser } from 'aws-amplify/analytics'; import { getCurrentUser } from 'aws-amplify/auth'; const location = { latitude: 47.606209, longitude: -122.332069, postalCode: '98122', city: 'Seattle', region: 'WA', country: 'USA' }; const attributes = { name: 'username', email: 'name@example.com', plan: 'plan', phoneNumber: '+11234567890', age: 25 }; const userProfile = { location, attributes }; async function sendUserData() { const user = await getCurrentUser(); identifyUser({ userId: user.userId, userProfile }); }
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 attributes = {
14 name: 'username',
15 email: 'name@example.com',
16 plan: 'plan',
17 phoneNumber: '+11234567890',
18 age: 25
19};
20
21const userProfile = {
22 location,
23 attributes
24};
25
26async function sendUserData() {
27 const user = await getCurrentUser();
28
29 identifyUser({
30 userId: user.userId,
31 userProfile
32 });
33}