Page updated Nov 14, 2023

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: "", plan: "plan", location: location, properties: properties ) Amplify.Analytics.identifyUser( userId: user.userId, userProfile: userProfile )
1let user = try await Amplify.Auth.getCurrentUser()
3let location = AnalyticsUserProfile.Location(
4 latitude: 47.606209,
5 longitude: -122.332069,
6 postalCode: "98122",
7 city: "Seattle",
8 region: "WA",
9 country: "USA"
12let properties: AnalyticsProperties = [
13 "phoneNumber": "+11234567890",
14 "age": 25
17let userProfile = AnalyticsUserProfile(
18 name: "username",
19 email: "",
20 plan: "plan",
21 location: location,
22 properties: properties
26 userId: user.userId,
27 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