Page updated Nov 9, 2023

Identify a user

To fully harness the potential of In-App Messaging, you must segment and target your In-App Messaging campaigns to specific user subsets. By identifying users with additional information, including their device demographics, location and any attributes of your choosing, you will be able to display intelligent, targeted in-app messages to the right users.

import { identifyUser } from 'aws-amplify/in-app-messaging'; const identifyUserInput = { userId: '', // E.g. user-id userProfile: { email: '', // E.g. example@service.com name: '', // E.g. name-of-the-user plan: '' // E.g. plan-they-subscribe-to customProperties: { // E.g. hobbies: ['cooking', 'knitting'], }, demographic: { appVersion: '', locale: '', // E.g. en_US make: '', // E.g. Apple model: '', // E.g. iPhone modelVersion: '', // E.g. 13 platform: '', // E.g. iOS platformVersion: '', // E.g. 15 timezone: '' // E.g. Americas/Los_Angeles }, location: { city: '', // E.g. Seattle country: '', // E.g. US, postalCode: '', // E.g. 98121 region: '', // E.g. WA latitude: 0.0, longitude: 0.0 }, metrics: { // E.g. logins: 157 }, }, }; await identifyUser(identifyUserInput);
1import { identifyUser } from 'aws-amplify/in-app-messaging';
2
3const identifyUserInput = {
4 userId: '', // E.g. user-id
5 userProfile: {
6 email: '', // E.g. example@service.com
7 name: '', // E.g. name-of-the-user
8 plan: '' // E.g. plan-they-subscribe-to
9 customProperties: {
10 // E.g. hobbies: ['cooking', 'knitting'],
11 },
12 demographic: {
13 appVersion: '',
14 locale: '', // E.g. en_US
15 make: '', // E.g. Apple
16 model: '', // E.g. iPhone
17 modelVersion: '', // E.g. 13
18 platform: '', // E.g. iOS
19 platformVersion: '', // E.g. 15
20 timezone: '' // E.g. Americas/Los_Angeles
21 },
22 location: {
23 city: '', // E.g. Seattle
24 country: '', // E.g. US,
25 postalCode: '', // E.g. 98121
26 region: '', // E.g. WA
27 latitude: 0.0,
28 longitude: 0.0
29 },
30 metrics: {
31 // E.g. logins: 157
32 },
33 },
34};
35
36await identifyUser(identifyUserInput);

Identify a user with Amazon Pinpoint

When using identifyUser with Amazon Pinpoint, in addition to the other user info properties you can configure the address, optOut and userAttributes properties under options.

import { identifyUser } from 'aws-amplify/in-app-messaging'; const identifyUserInput = { userId: '', // E.g. user-id options: { address: '' // E.g. A device token or email address optOut: '' // Either ALL or NONE userAttributes: { // E.g. interests: ['soccer', 'shoes'], } }, }; await identifyUser(identifyUserInput);
1import { identifyUser } from 'aws-amplify/in-app-messaging';
2
3const identifyUserInput = {
4 userId: '', // E.g. user-id
5 options: {
6 address: '' // E.g. A device token or email address
7 optOut: '' // Either ALL or NONE
8 userAttributes: {
9 // E.g. interests: ['soccer', 'shoes'],
10 }
11 },
12
13};
14
15await identifyUser(identifyUserInput);