Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Identify user

This call sends information about the current user (which could be unauthenticated or authenticated) to Amazon Pinpoint.

You can provide name, email and plan, as well as location information with AnalyticsUserProfile.Location. You can also send additional custom attributes using AnalyticsProperties.

If the user is signed in through Amplify.Auth.signIn, then you can retrieve the current user's ID as shown below:

let user = try await Amplify.Auth.getCurrentUser()
let location = AnalyticsUserProfile.Location(
latitude: 47.606209,
longitude: -122.332069,
postalCode: "98122",
city: "Seattle",
region: "WA",
country: "USA"
)
let properties: AnalyticsProperties = [
"phoneNumber": "+11234567890",
"age": 25
]
let userProfile = AnalyticsUserProfile(
name: "username",
email: "name@example.com",
plan: "plan",
location: location,
properties: properties
)
Amplify.Analytics.identifyUser(
userId: user.userId,
userProfile: userProfile
)

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