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

Page updated May 3, 2024

Identify user

AWS will end support for Amazon Pinpoint on October 30, 2026,, and is no longer accepting any new users as of May 20 (see the linked doc). The guidance is to use AWS End User Messaging for push notifications and SMS, Amazon Simple Email Service for sending emails, Amazon Connect for campaigns, journeys, endpoints, and engagement analytics. Pinpoint recommends Amazon Kinesis for event collection and mobile analytics.

This call sends information that you have specified about the user to Amazon Pinpoint. This could be for an unauthenticated or an authenticated user.

In addition, customProperties and userAttributes can also be provided when invoking identifyUser. The Amazon Pinpoint console makes that data available as part of the criteria for segment creation. Attributes passed in via customProperties will appear under Custom Endpoint Attributes, while userAttributes will appear under Custom User Attributes. See the Amazon Pinpoint documentation for more information on segment creation.

You can get the current user's ID from the Amplify Auth category as shown below. Be sure you have it added and setup per the Auth category documentation.

If you have asked for location access and received permission, you can also provide that in UserProfile.Location.

UserProfile.Location location = UserProfile.Location.builder()
.latitude(47.606209)
.longitude(-122.332069)
.postalCode("98122")
.city("Seattle")
.region("WA")
.country("USA")
.build();
AnalyticsProperties customProperties = AnalyticsProperties.builder()
.add("property1", "Property value")
.build();
AnalyticsProperties userAttributes = AnalyticsProperties.builder()
.add("someUserAttribute", "User attribute value")
.build();
AWSPinpointUserProfile profile = AWSPinpointUserProfile.builder()
.name("test-user")
.email("user@test.com")
.plan("test-plan")
.location(location)
.customProperties(customProperties)
.userAttributes(userAttributes)
.build();
Amplify.Auth.getCurrentUser(authUser -> {
String userId = authUser.getUserId();
Amplify.Analytics.identifyUser(userId, profile);
}, exception -> {
Log.e("MyAmplifyApp", "Error getting current user", exception);
});
val location = UserProfile.Location.builder()
.latitude(47.606209)
.longitude(-122.332069)
.postalCode("98122")
.city("Seattle")
.region("WA")
.country("USA")
.build();
val customProperties = AnalyticsProperties.builder()
.add("property1", "Property value")
.build();
val userAttributes = AnalyticsProperties.builder()
.add("someUserAttribute", "User attribute value")
.build();
val profile = AWSPinpointUserProfile.builder()
.name("test-user")
.email("user@test.com")
.plan("test-plan")
.location(location)
.customProperties(customProperties)
.userAttributes(userAttributes)
.build();
Amplify.Auth.getCurrentUser({ authUser ->
Amplify.Analytics.identifyUser(authUser.userId, profile);
}, { exception ->
Log.e("MyAmplifyApp", "Error getting current user", exception)
})
UserProfile.Location location = UserProfile.Location.builder()
.latitude(47.606209)
.longitude(-122.332069)
.postalCode("98122")
.city("Seattle")
.region("WA")
.country("USA")
.build();
AnalyticsProperties customProperties = AnalyticsProperties.builder()
.add("property1", "Property value")
.build();
AnalyticsProperties userAttributes = AnalyticsProperties.builder()
.add("someUserAttribute", "User attribute value")
.build();
AWSPinpointUserProfile profile = AWSPinpointUserProfile.builder()
.name("test-user")
.email("user@test.com")
.plan("test-plan")
.location(location)
.customProperties(customProperties)
.userAttributes(userAttributes)
.build();
RxAmplify.Auth.getCurrentUser()
.subscribe(
result -> {
String userId = result.getUserId();
RxAmplify.Analytics.identifyUser(userId, profile);
},
error -> Log.e("AuthQuickStart", error.toString())
);

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