ユーザー ID の設定
Braze SDKでユーザーIDを設定する方法を学習する。これは、デバイスやプラットフォームを超えてユーザーを追跡し、ユーザーデータAPIを通じてユーザーデータをインポートし、メッセージングAPIを通じてターゲットメッセージを送信するための一意の識別子である。ユーザーに固有のIDを割り当てない場合、Brazeは代わりに匿名IDを割り当てるが、割り当てるまでこれらの機能を使用することはできない。
リストにないラッパーSDKについては、代わりに関連するAndroidまたはSwiftのネイティブ・メソッドを使用する。
匿名ユーザーについて
After you integrate the Braze SDK, users who launch your app for the first time will be considered “anonymous” until you call the changeUser
method and assign them an external_id
. Once assigned, you can’t make them anonymous again. However, if they uninstall and reinstall your app, they will become anonymous again until changeUser
is called.
If a previously-identified user starts a session on a new device, all of their anonymous activity will automatically sync to their existing profile after you call changeUser
on that device using their external_id
. This includes any attributes, events, or history collected during the session on the new device.
ユーザーIDの設定
ユーザーIDを設定するには、ユーザーが最初にログインした後、changeUser()
メソッドを呼び出す。IDは一意でなければならず、私たちの命名のベストプラクティスに従わなければならない。
代わりに一意な識別子をハッシュする場合は、ハッシュ関数の入力を正規化するようにしてほしい。例えば、メールアドレスをハッシュ化する場合、先頭や末尾のスペースを取り除き、ローカライゼーションを考慮する。
1
Braze.getInstance(context).changeUser(YOUR_USER_ID_STRING);
1
Braze.getInstance(context).changeUser(YOUR_USER_ID_STRING)
1
AppDelegate.braze?.changeUser(userId: "YOUR_USER_ID")
1
[AppDelegate.braze changeUser:@"YOUR_USER_ID_STRING"];
標準的なWeb SDK実装の場合、以下の方法を使用できる:
1
braze.changeUser(YOUR_USER_ID_STRING);
代わりにGoogle Tag Managerを使いたい場合は、Change Userタグタイプを使ってchangeUser
メソッドを呼び出すことができる。ユーザーがログインするとき、あるいは一意の識別子(external_id
)で識別されるときは、必ずこれを使用する。
現行のユーザーの一意のID を外部ユーザー ID フィールドに入力してください。通常は、Web サイトから送信されたデータレイヤー変数を使用して入力します。
1
BrazePlugin.changeUser("YOUR_USER_ID");
1
m.Braze.setUserId(YOUR_USER_ID_STRING)
1
AppboyBinding.ChangeUser("YOUR_USER_ID_STRING");
1
UBraze->ChangeUser(TEXT("YOUR_USER_ID_STRING"));
ユーザーがログアウトしたときに、固定デフォルトIDやコールchangeUser()
を割り当てないこと。そうすることで、共有デバイスに以前ログインしたユーザーを再度エンゲージメントすることができなくなる。その代わりに、すべてのユーザーIDを別々に管理し、アプリのログアウト・プロセスで以前にログインしたユーザーに切り替えることができるようにする。新しいセッションが始まると、Brazeは新しくアクティブになったプロファイルのデータを自動的にリフレッシュする。
ユーザーのエイリアス
仕組み
Although anonymous users don’t have external_ids
, you can assign them a user alias instead. You should assign a user alias when you want to add other identifiers to the user but don’t know what their external_id
is (for example, they aren’t logged in). With user aliases, you also can:
- Use the Braze API to log events and attributes associated with anonymous users
- Use the External User ID is blank segmentation filter to target anonymous users in your messaging
ユーザーエイリアスの設定
ユーザーエイリアスは、名前とラベルの2つの部分で構成される。名前は識別子そのものを指し、ラベルはその識別子が属するタイプを指す。例えば、サードパーティのカスタマーサポートプラットフォームに外部ID987654
を持つユーザーがいる場合、Brazeでそのユーザーに987654
という名前とsupport_id
というラベルのエイリアスを割り当てることで、プラットフォーム間でそのユーザーを追跡することができる。
1
Braze.getInstance(context).getCurrentUser().addAlias(ALIAS_NAME, ALIAS_LABEL);
1
Braze.getInstance(context).currentUser?.addAlias(ALIAS_NAME, ALIAS_LABEL)
1
Appboy.sharedInstance()?.user.addAlias(ALIAS_NAME, ALIAS_LABEL)
1
[[Appboy sharedInstance].user addAlias:ALIAS_NAME withLabel:ALIAS_LABEL];
1
braze.getUser().addAlias(ALIAS_NAME, ALIAS_LABEL);
1
2
3
4
{
"alias_name" : (required, string),
"alias_label" : (required, string)
}
IDネーミングのベストプラクティス
ユーザーIDはUniversally Unique Identifier(UUID)標準を使って作成することを推奨する。
あるいは、既存の一意識別子(名前やメール・アドレスなど)をハッシュ化してユーザーIDを生成することもできる。その場合は、必ずSDK認証を実装し、ユーザーの偽装やなりすましを防いでほしい。
ユーザーIDに最初から正しい名前を付けることは不可欠だが、将来的にはいつでも /users/external_ids/rename
エンドポイントを使って変更できる。
おすすめ | 推奨しない |
---|---|
123e4567-e89b-12d3-a456-836199333115 | JonDoe829525552 |
8c0b3728-7fa7-4c68-a32e-12de1d3ed2d5 | [email protected] |
f0a9b506-3c5b-4d86-b16a-94fc4fc3f7b0 | CompanyName-1-2-19 |
2d9e96a1-8f15-4eaf-bf7b-eb8c34e25962 | jon-doe-1-2-19 |
ユーザーIDの作成方法の詳細を共有することは、悪意のある攻撃やユーザーデータの持ち出しに組織をさらす可能性があるため、避けること。