ユーザー属性を設定する
Braze SDKを通してユーザー属性を設定する方法を学習する。

リストされていないラッパーSDK の場合は、代わりに関連するネイティブAndroid またはSwift メソッドを使用します。
前提条件
この機能を使用する前に、Web Braze SDKを統合する必要がある。
デフォルトのユーザー属性
定義済みメソッド
Brazeは、Userクラス内で以下のユーザー属性を設定するための定義済みメソッドを提供しています:
- 名
- 姓
- 言語
- 国
- 生年月日
- メール
- 性別
- 市区町村
- 電話番号
デフォルト属性の設定
ユーザーにデフォルト属性を設定するには、BrazeインスタンスのgetUser()メソッドを呼び出して、アプリの現在のユーザーへの参照を取得します。その後、メソッドを呼び出してユーザー属性を設定できます。
1
braze.getUser().setFirstName("SomeFirstName");
braze.getUser().setGender(braze.User.Genders.FEMALE);
braze.getUser().setDateOfBirth(2000, 12, 25);
Google Tag Managerを使用する場合、標準属性項目(ユーザーの名など)は、カスタムユーザー属性と同様の方法で記録します。標準属性項目に渡す値が、Userクラスのドキュメントで指定されている想定される形式と一致していることを確認してください。
たとえば、性別属性は、値として次のいずれかを使用できます: "m" | "f" | "o" | "u" | "n" | "p"。したがって、ユーザーの性別を女性に設定するには、次の内容のカスタムHTMLタグを作成します:
<script>
window.braze.getUser().setGender("f")
</script>
デフォルト属性の解除
ユーザー属性の削除や解除は、アプリコード、REST APIリクエスト、またはユーザーの更新キャンバスステップを通じて行うことができます。配列およびブール値の属性にはnullを使用します。その他のデータタイプには空の文字列("")を使用します。
Web SDKでデフォルトのユーザー属性を解除するには、関連するメソッドにnullを渡します。以下に例を示します:
braze.getUser().setFirstName(null);
braze.getUser().setGender(null);
braze.getUser().setDateOfBirth(null, null, null);
カスタムユーザー属性
カスタム属性の設定
デフォルトのユーザー属性メソッドに加えて、ユーザーに対してカスタム属性を設定することもできます。完全なメソッド仕様については、JSDocsを参照してください。
string値でカスタム属性を設定するには:
braze.getUser().setCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
YOUR_STRING_VALUE
);
integer値でカスタム属性を設定するには:
braze.getUser().setCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
YOUR_INT_VALUE
);
// Integer attributes may also be incremented using code like the following
braze.getUser().incrementCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
THE_INTEGER_VALUE_BY_WHICH_YOU_WANT_TO_INCREMENT_THE_ATTRIBUTE
);
date値でカスタム属性を設定するには:
braze.getUser().setCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
YOUR_DATE_VALUE
);
// This method will assign the current time to a custom attribute at the time the method is called
braze.getUser().setCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
new Date()
);
// This method will assign the date specified by secondsFromEpoch to a custom attribute
braze.getUser().setCustomUserAttribute(
YOUR_ATTRIBUTE_KEY_STRING,
new Date(secondsFromEpoch * 1000)
);
配列のデフォルトおよび最大要素数は500です。最大要素数は、Brazeダッシュボードのデータ設定 > カスタム属性で更新できます。最大要素数を超える配列は、最大要素数に切り詰められます。
array値でカスタム属性を設定するには:
braze.getUser().setCustomUserAttribute(YOUR_ATTRIBUTE_KEY_STRING, YOUR_ARRAY_OF_STRINGS);
// Adding a new element to a custom attribute with an array value
braze.getUser().addToCustomAttributeArray(YOUR_ATTRIBUTE_KEY_STRING, "new string");
// Removing an element from a custom attribute with an array value
braze.getUser().removeFromCustomAttributeArray(YOUR_ATTRIBUTE_KEY_STRING, "value to be removed");

このメソッドでBrazeに渡される日付は、JavaScriptのDateオブジェクトでなければなりません。

カスタム属性のキーと値は、最大255文字までです。有効なカスタム属性の値に関する詳細については、リファレンスドキュメントを参照してください。
Google Tag Managerのスクリプト言語の制限により、カスタムユーザー属性は使用できません。カスタム属性を記録するには、次の内容でカスタムHTMLタグを作成します:
<script>
// Note: If using SDK version 3.x or below, use `window.appboy` instead of `window.braze`
// Version 4 or greater should use `window.braze`
window.braze.getUser().setCustomUserAttribute("attribute name", "attribute value");
</script>

GTMテンプレートでは、イベントまたは購入のネストされたプロパティはサポートされていません。前述のHTMLを使用して、ネストされたプロパティを必要とするイベントや購入を記録できます。
カスタム属性の設定解除
カスタム属性を解除するには、関連するメソッドにnullを渡します。
braze.getUser().setCustomUserAttribute(YOUR_ATTRIBUTE_KEY_STRING, null);
階層化カスタム属性
カスタム属性内にプロパティをネストすることもできます。次の例では、ネストされたプロパティを持つfavorite_bookオブジェクトが、ユーザープロファイルのカスタム属性として設定されています。詳細については、階層化カスタム属性を参照してください。
import * as braze from "@braze/web-sdk";
const favoriteBook = {
title: "The Hobbit",
author: "J.R.R. Tolkien",
publishing_date: "1937"
};
braze.getUser().setCustomUserAttribute("favorite_book", favoriteBook);
REST APIの使用
ユーザー属性の設定や解除には、REST APIも使用できます。詳細については、ユーザーデータエンドポイントを参照してください。
ユーザーサブスクリプションの設定
ユーザーのサブスクリプション(メールまたはプッシュ)を設定するには、それぞれ関数setEmailNotificationSubscriptionType()またはsetPushNotificationSubscriptionType()を呼び出します。両方の関数はenum型braze.User.NotificationSubscriptionTypesを引数として取ります。この型には、次の3つの状態があります:
| サブスクリプションのステータス | 定義 |
|---|---|
braze.User.NotificationSubscriptionTypes.OPTED_IN |
配信登録済み、かつ明示的にオプトイン済み |
braze.User.NotificationSubscriptionTypes.SUBSCRIBED |
購読中、ただし明示的にオプトインしていない |
braze.User.NotificationSubscriptionTypes.UNSUBSCRIBED |
配信停止済みまたは明示的にオプトアウト済み、あるいはその両方 |
ユーザーがプッシュに登録されると、ブラウザは通知を許可するかブロックするかの選択を求めます。プッシュを許可することを選択した場合、デフォルトでOPTED_INに設定されます。
サブスクリプションと明示的なオプトインの実装に関する詳細については、ユーザーのサブスクリプションの管理を参照してください。
ユーザーのメール配信停止
braze.getUser().setEmailNotificationSubscriptionType(braze.User.NotificationSubscriptionTypes.UNSUBSCRIBED);
ユーザーのプッシュ通知の配信停止
braze.getUser().setPushNotificationSubscriptionType(braze.User.NotificationSubscriptionTypes.UNSUBSCRIBED);
前提条件
この機能を使用する前に、Android Braze SDKを統合する必要がある。
デフォルトのユーザー属性
定義済みメソッド
Brazeは、BrazeUserクラス内で以下のユーザー属性を設定するための定義済みメソッドを提供しています。メソッド仕様については、KDocを参照してください。
- 名
- 姓
- 国
- 言語
- 生年月日
- メール
- 性別
- 市区町村
- 電話番号

姓、名、国、市区町村などの文字列値はすべて255文字に制限されています。
デフォルト属性の設定
ユーザーにデフォルト属性を設定するには、BrazeインスタンスのgetCurrentUser()メソッドを呼び出して、アプリの現在のユーザーへの参照を取得します。その後、メソッドを呼び出してユーザー属性を設定できます。
1
2
3
4
5
6
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setFirstName("first_name");
}
}
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setFirstName("first_name")
}
デフォルト属性の解除
ユーザー属性を解除するには、該当するメソッドにnullを渡します。
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setFirstName(null);
}
}
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setFirstName(null)
}
カスタムユーザー属性
デフォルトのユーザー属性に加えて、Brazeでは複数の異なるデータタイプを使用してカスタム属性を定義することもできます。各属性のセグメンテーションオプションの詳細については、ユーザーデータ収集を参照してください。
カスタム属性の設定
カスタム属性をstring値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", "your_attribute_value");
}
}
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", "your_attribute_value")
}
カスタム属性をint値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_INT_VALUE);
// Integer attributes may also be incremented using code like the following:
brazeUser.incrementCustomUserAttribute("your_attribute_key", YOUR_INCREMENT_VALUE);
}
}
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_INT_VALUE)
// Integer attributes may also be incremented using code like the following:
brazeUser.incrementCustomUserAttribute("your_attribute_key", YOUR_INCREMENT_VALUE)
}
カスタム属性をlong整数値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_LONG_VALUE);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_LONG_VALUE)
}
カスタム属性をfloat値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_FLOAT_VALUE);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_FLOAT_VALUE)
}
カスタム属性をdouble値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_DOUBLE_VALUE);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_DOUBLE_VALUE)
}
カスタム属性をboolean値で設定するには:
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_BOOLEAN_VALUE);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_BOOLEAN_VALUE)
}
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_DATE_VALUE);
// This method will assign the current time to a custom attribute at the time the method is called:
brazeUser.setCustomUserAttributeToNow("your_attribute_key");
// This method will assign the date specified by SECONDS_FROM_EPOCH to a custom attribute:
brazeUser.setCustomUserAttributeToSecondsFromEpoch("your_attribute_key", SECONDS_FROM_EPOCH);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setCustomUserAttribute("your_attribute_key", YOUR_DATE_VALUE)
// This method will assign the current time to a custom attribute at the time the method is called:
brazeUser.setCustomUserAttributeToNow("your_attribute_key")
// This method will assign the date specified by SECONDS_FROM_EPOCH to a custom attribute:
brazeUser.setCustomUserAttributeToSecondsFromEpoch("your_attribute_key", SECONDS_FROM_EPOCH)
}

このメソッドでBrazeに渡される日付は、ISO 8601形式(例:2013-07-16T19:20:30+01:00)またはyyyy-MM-dd'T'HH:mm:ss:SSSZ形式(例:2016-12-14T13:32:31.601-0800)のいずれかである必要があります。
配列内の要素のデフォルトおよび最大数は500です。最大数はBrazeダッシュボードのデータ設定 > カスタム属性で更新できます。要素数が最大値を超える配列は、最大要素数に切り詰められます。カスタム属性配列とその動作の詳細については、配列を参照してください。
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
// Setting a custom attribute with an array value
brazeUser.setCustomAttributeArray("your_attribute_key", testSetArray);
// Adding to a custom attribute with an array value
brazeUser.addToCustomAttributeArray("your_attribute_key", "value_to_add");
// Removing a value from an array type custom attribute
brazeUser.removeFromCustomAttributeArray("your_attribute_key", "value_to_remove");
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
// Setting a custom attribute with an array value
brazeUser.setCustomAttributeArray("your_attribute_key", testSetArray)
// Adding to a custom attribute with an array value
brazeUser.addToCustomAttributeArray("your_attribute_key", "value_to_add")
// Removing a value from an array type custom attribute
brazeUser.removeFromCustomAttributeArray("your_attribute_key", "value_to_remove")
}
カスタム属性の設定解除
カスタム属性を解除するには、該当する属性キーをunsetCustomUserAttributeメソッドに渡します。
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.unsetCustomUserAttribute("your_attribute_key");
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.unsetCustomUserAttribute("your_attribute_key")
}
階層化カスタム属性
カスタム属性内にプロパティをネストすることもできます。次の例では、ネストされたプロパティを持つfavorite_bookオブジェクトが、ユーザープロファイルのカスタム属性として設定されます。詳細については、階層化カスタム属性を参照してください。
JSONObject favoriteBook = new JSONObject();
try {
favoriteBook.put("title", "The Hobbit");
favoriteBook.put("author", "J.R.R. Tolkien");
favoriteBook.put("publishing_date", "1937");
} catch (JSONException e) {
e.printStackTrace();
}
braze.getCurrentUser(user -> {
user.setCustomUserAttribute("favorite_book", favoriteBook);
return null;
});
val favoriteBook = JSONObject()
.put("title", "The Hobbit")
.put("author", "J.R.R. Tolkien")
.put("publishing_date", "1937")
braze.getCurrentUser { user ->
user.setCustomUserAttribute("favorite_book", favoriteBook)
}
REST APIの使用
ユーザー属性の設定や解除には、REST APIも使用できます。詳細については、ユーザーデータエンドポイントを参照してください。
ユーザーサブスクリプションの設定
ユーザーのサブスクリプション(メールまたはプッシュ)を設定するには、それぞれsetEmailNotificationSubscriptionType()関数またはsetPushNotificationSubscriptionType()関数を呼び出します。これらの関数はいずれも引数として列挙型NotificationSubscriptionTypeを受け取ります。この型には、次の3つの状態があります。
| サブスクリプションステータス | 定義 |
|---|---|
OPTED_IN |
配信登録済み、かつ明示的にオプトイン済み |
SUBSCRIBED |
購読中、ただし明示的にオプトインしていない |
UNSUBSCRIBED |
配信停止済みまたは明示的にオプトアウト済み、あるいはその両方 |

Androidでは、ユーザーにプッシュ通知を送信する際に明示的なオプトインは必要ありません。ユーザーがプッシュ登録されると、デフォルトでOPTED_INではなくSUBSCRIBEDに設定されます。サブスクリプションと明示的オプトインの実装の詳細については、ユーザーサブスクリプションの管理を参照してください。
メールサブスクリプションの設定
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setEmailNotificationSubscriptionType(emailNotificationSubscriptionType);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setEmailNotificationSubscriptionType(emailNotificationSubscriptionType)
}
プッシュ通知サブスクリプションの設定
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
@Override
public void onSuccess(BrazeUser brazeUser) {
brazeUser.setPushNotificationSubscriptionType(pushNotificationSubscriptionType);
}
});
Braze.getInstance(context).getCurrentUser { brazeUser ->
brazeUser.setPushNotificationSubscriptionType(pushNotificationSubscriptionType)
}
前提条件
この機能を使う前に、Swift Braze SDKを統合する必要がある。
デフォルトのユーザー属性
サポートされている属性
以下の属性は Braze.User オブジェクトで設定する必要があります。
firstNamelastNameemaildateOfBirthcountrylanguagehomeCityphonegender
デフォルト属性の設定
デフォルトのユーザー属性を設定するには、共有 Braze.User オブジェクトの適切なフィールドを設定します。以下は名属性の設定例です。
1
AppDelegate.braze?.user.set(firstName: "Alex")
[AppDelegate.braze.user setFirstName:@"Alex"];
デフォルト属性の解除
デフォルトのユーザー属性を解除するには、関連するメソッドに nil を渡します。
AppDelegate.braze?.user.set(firstName: nil)
[AppDelegate.braze.user setFirstName:nil];
カスタムユーザー属性
デフォルトのユーザー属性に加えて、Brazeでは複数の異なるデータタイプを使用してカスタム属性を定義することもできます。各属性のセグメンテーションオプションの詳細については、ユーザーデータ収集を参照してください。

カスタム属性値の最大長は255文字です。これより長い値は切り捨てられます。詳細については、Braze.Userを参照してください。
カスタム属性の設定
string 値でカスタム属性を設定するには:
AppDelegate.braze?.user.setCustomAttribute(key: "your_attribute_key", value: "your_attribute_value")
[AppDelegate.braze.user setCustomAttributeWithKey:@"your_attribute_key" stringValue:"your_attribute_value"];
integer 値でカスタム属性を設定するには:
AppDelegate.braze?.user.setCustomAttribute(key: "your_attribute_key", value: yourIntegerValue)
[AppDelegate.braze.user setCustomAttributeWithKey:@"your_attribute_key" andIntegerValue:yourIntegerValue];
Brazeでは、データベース内での float 値と double 値の扱いが同じです。倍精度値でカスタム属性を設定するには:
AppDelegate.braze?.user.setCustomAttribute(key: "your_attribute_key", value: yourDoubleValue)
[AppDelegate.braze.user setCustomAttributeWithKey:@"your_attribute_key" andDoubleValue:yourDoubleValue];
boolean 値でカスタム属性を設定するには:
AppDelegate.braze?.user.setCustomAttribute("your_attribute_key", value: yourBoolValue)
[AppDelegate.braze.user setCustomAttributeWithKey:@"your_attribute_key" andBOOLValue:yourBOOLValue];
date 値でカスタム属性を設定するには:
AppDelegate.braze?.user.setCustomAttribute("your_attribute_key", dateValue:yourDateValue)
[AppDelegate.braze.user setCustomAttributeWithKey:@"your_attribute_key" andDateValue:yourDateValue];
配列内の要素のデフォルトおよび最大数は500です。最大数はBrazeダッシュボードのデータ設定 > カスタム属性で更新できます。要素の最大数を超える配列は、最大数の要素を含むように切り捨てられます。
array 値でカスタム属性を設定するには:
// Setting a custom attribute with an array value
AppDelegate.braze?.user.setCustomAttributeArray(key: "array_name", array: ["value1", "value2"])
// Adding to a custom attribute with an array value
AppDelegate.braze?.user.addToCustomAttributeArray(key: "array_name", value: "value3")
// Removing a value from an array type custom attribute
AppDelegate.braze?.user.removeFromCustomAttributeArray(key: "array_name", value: "value2")
// Setting a custom attribute with an array value
[AppDelegate.braze.user setCustomAttributeArrayWithKey:@"array_name" array:@[@"value1", @"value2"]];
// Adding to a custom attribute with an array value
[AppDelegate.braze.user addToCustomAttributeArrayWithKey:@"array_name" value:@"value3"];
// Removing a value from an array type custom attribute
[AppDelegate.braze.user removeFromCustomAttributeArrayWithKey:@"array_name" value:@"value2"];
// Removing an entire array and key
[AppDelegate.braze.user setCustomAttributeArrayWithKey:@"array_name" array:nil];
カスタム属性の増減
このコードは、カスタム属性のインクリメントの例です。カスタム属性の値は、任意の integer または long の値で増加させることができます。
AppDelegate.braze?.user.incrementCustomUserAttribute(key: "your_attribute_key", by: incrementIntegerValue)
[AppDelegate.braze.user incrementCustomUserAttribute:@"your_attribute_key" by:incrementIntegerValue];
カスタム属性の設定解除
カスタム属性を解除するには、該当する属性キーを unsetCustomAttribute メソッドに渡します。
AppDelegate.braze?.user.unsetCustomAttribute(key: "your_attribute_key")
カスタム属性を解除するには、該当する属性キーを unsetCustomAttributeWithKey メソッドに渡します。
[AppDelegate.braze.user unsetCustomAttributeWithKey:@"your_attribute_key"];
階層化カスタム属性
カスタム属性内にプロパティをネストすることもできます。次の例では、ネストされたプロパティを持つ favorite_book オブジェクトが、ユーザープロファイルのカスタム属性として設定されます。詳細については、階層化カスタム属性を参照してください。
let favoriteBook: [String: Any?] = [
"title": "The Hobbit",
"author": "J.R.R. Tolkien",
"publishing_date": "1937"
]
braze.user.setCustomAttribute(key: "favorite_book", dictionary: favoriteBook)
NSDictionary *favoriteBook = @{
@"title": @"The Hobbit",
@"author": @"J.R.R. Tolkien",
@"publishing_date": @"1937"
};
[AppDelegate.braze.user setCustomAttributeWithKey:@"favorite_book" dictionary:favoriteBook];
REST APIの使用
ユーザー属性を設定または解除するには、REST APIも利用できます。詳細については、ユーザーデータエンドポイントを参照してください。
ユーザーサブスクリプションの設定
ユーザーのサブスクリプション(メールまたはプッシュ)を設定するには、それぞれ関数 set(emailSubscriptionState:) または set(pushNotificationSubscriptionState:) を呼び出します。これらの関数では、いずれも引数として列挙型 Braze.User.SubscriptionState が使用されます。この型には、次の3つの状態があります。
| サブスクリプションのステータス | 定義 |
|---|---|
optedIn |
配信登録済み、かつ明示的にオプトイン済み |
subscribed |
購読中、ただし明示的にオプトイン済みではない |
unsubscribed |
配信停止済みまたは明示的にオプトアウト済み、あるいはその両方 |
アプリにプッシュ通知の送信を許可したユーザーは、iOSで明示的なオプトインが必要であるため、デフォルトでステータスが optedIn に設定されます。
ユーザーは、有効なメールアドレスを受信すると自動的に subscribed に設定されます。ただし、明示的なオプトインのプロセスを確立し、ユーザーから明示的な同意を得た時点でこの値を optedIn に設定することをお勧めします。詳細については、「ユーザーサブスクリプションの管理」を参照してください。
メールサブスクリプションの設定
AppDelegate.braze?.user.set(emailSubscriptionState: Braze.User.SubscriptionState)
[AppDelegate.braze.user setEmailSubscriptionState: BRZUserSubscriptionState]
プッシュ通知サブスクリプションの設定
AppDelegate.braze?.user.set(pushNotificationSubscriptionState: Braze.User.SubscriptionState)
[AppDelegate.braze.user setPushNotificationSubscriptionState: BRZUserSubscriptionState]
詳細については、「ユーザーサブスクリプションの管理」を参照してください。
前提条件
この機能を使う前に、Flutter Braze SDKを統合する必要がある。
デフォルトのユーザー属性
サポートされている属性
以下の属性がサポートされています。
- 名
- 姓
- 性別
- 生年月日
- 市区町村
- 国
- 電話番号
- 言語
- メール

姓、名、国、市区町村などの文字列値はすべて255文字に制限されています。
デフォルト属性の設定
Brazeが自動的に収集したユーザー属性を設定するには、SDKに付属のセッターメソッドを使用する。
1
braze.setFirstName('Name');
カスタムユーザー属性
カスタム属性の設定
デフォルトのユーザー属性に加え、Brazeでは様々なデータタイプを使用してカスタム属性を定義することができる:
string 、カスタム属性を設定する:
braze.setStringCustomUserAttribute("custom string attribute", "string custom attribute");
integer 、カスタム属性を設定する:
// Set Integer Attribute
braze.setIntCustomUserAttribute("custom int attribute key", integer);
// Increment Integer Attribute
braze.incrementCustomUserAttribute("key", integer);
double 、カスタム属性を設定する:
braze.setDoubleCustomUserAttribute("custom double attribute key", double);
boolean 、カスタム属性を設定する:
braze.setBoolCustomUserAttribute("custom boolean attribute key", boolean);
date 、カスタム属性を設定する:
braze.setDateCustomUserAttribute("custom date attribute key", date);
array 、カスタム属性を設定する:
// Adding to an Array
braze.addToCustomAttributeArray("key", "attribute");
// Removing an item from an Array
braze.removeFromCustomAttributeArray("key", "attribute");

カスタム属性値の最大長は 255 文字です。これより長い値は切り捨てられます。
カスタム属性の設定を解除する
カスタム属性を解除するには、unsetCustomUserAttribute メソッドに関連する属性キーを渡す。
braze.unsetCustomUserAttribute('attribute_key');
前提条件
この機能を使用するには、 Roku Braze SDK を統合する必要があります。
デフォルトのユーザー属性
定義済みメソッド
Brazeは、m.Brazeオブジェクトを使用して以下のユーザー属性を設定するための定義済みメソッドを提供しています。
FirstNameLastNameEmailGenderDateOfBirthCountryLanguageHomeCityPhoneNumber
デフォルト属性の設定
デフォルト属性を設定するには、m.Brazeオブジェクトの関連メソッドを呼び出します。
1
m.Braze.setFirstName("Alex")
m.Braze.setLastName("Smith")
m.Braze.setEmail("[email protected]")
m.Braze.setGender("m") ' Accepts: "m", "f", "o", "n", "u", "p"
m.Braze.setDateOfBirth(1990, 5, 15) ' Year, month, day
m.Braze.setCountry("United States")
m.Braze.setLanguage("en")
m.Braze.setHomeCity("New York")
m.Braze.setPhoneNumber("+1234567890")
カスタムユーザー属性
デフォルトのユーザー属性に加え、Brazeではいくつかのデータタイプを使用してカスタム属性を定義することもできます。
カスタム属性の設定
string値でカスタム属性を設定するには:
m.Braze.setCustomAttribute("stringAttribute", "stringValue")
integer値でカスタム属性を設定するには:
m.Braze.setCustomAttribute("intAttribute", 5)
Brazeは、floatとdoubleの値をまったく同じように扱います。いずれかの値でカスタム属性を設定するには:
m.Braze.setCustomAttribute("floatAttribute", 3.5)
boolean値でカスタム属性を設定するには:
m.Braze.setCustomAttribute("boolAttribute", true)
date値でカスタム属性を設定するには:
dateAttribute = CreateObject("roDateTime")
dateAttribute.fromISO8601String("1992-11-29 00:00:00.000")
m.Braze.setCustomAttribute("dateAttribute", dateAttribute)
array値でカスタム属性を設定するには:
stringArray = createObject("roArray", 3, true)
stringArray.Push("string1")
stringArray.Push("string2")
stringArray.Push("string3")
m.Braze.setCustomAttribute("arrayAttribute", stringArray)

カスタム属性値の最大長は255文字です。これより長い値は切り捨てられます。
カスタム属性のインクリメントとデクリメント
このコードは、カスタム属性のインクリメントの例です。カスタム属性の値は、正または負の整数値でインクリメントできます。
m.Braze.incrementCustomUserAttribute("intAttribute", 3)
カスタム属性の設定解除
カスタム属性を解除するには、unsetCustomAttributeメソッドに関連する属性キーを渡します。
m.Braze.unsetCustomAttribute("attributeName")
REST APIの使用
REST APIを使用して、ユーザー属性を設定または解除することもできます。詳細については、ユーザーデータエンドポイントを参照してください。
メールサブスクリプションの設定
SDKから、ユーザーに対して以下のメールのサブスクリプションステータスをプログラムで設定できます。
| サブスクリプションのステータス | 定義 |
|---|---|
OptedIn |
購読中、かつ明示的にオプトイン済み |
Subscribed |
購読中、ただし明示的にオプトインしていない |
UnSubscribed |
配信停止済みまたは明示的にオプトアウト済み、あるいはその両方 |

これらのタイプはBrazeConstants().SUBSCRIPTION_STATESに属します。
メールのサブスクリプションステータスを設定するメソッドはsetEmailSubscriptionState()です。ユーザーは、有効なメールアドレスを受信すると自動的にSubscribedに設定されます。ただし、明示的なオプトインのプロセスを確立し、ユーザーから明示的な同意を得た時点でこの値をOptedInに設定することをお勧めします。詳細については、ユーザーサブスクリプションの管理を参照してください。
m.Braze.setEmailSubscriptionState(BrazeConstants().SUBSCRIPTION_STATES.OPTED_IN)
前提条件
この機能を使用する前に、Unity Braze SDKを統合する必要がある。
デフォルトのユーザー属性
定義済みメソッド
Brazeは、BrazeBindingオブジェクトを使用して以下のユーザー属性を設定するための定義済みメソッドを提供しています。詳しくはBraze Unity宣言ファイルを参照してください。
- 名
- 姓
- ユーザーのメールアドレス
- 性別
- 生年月日
- ユーザーの国
- ユーザーの市区町村
- ユーザーのメールサブスクリプション
- ユーザーのプッシュサブスクリプション
- ユーザーの電話番号
デフォルト属性の設定
デフォルト属性を設定するには、BrazeBindingオブジェクトの関連メソッドを呼び出します。
1
BrazeBinding.SetUserFirstName("first name");
BrazeBinding.SetUserLastName("last name");
BrazeBinding.SetUserEmail("[email protected]");
BrazeBinding.SetUserGender(Appboy.Models.Gender);
BrazeBinding.SetUserDateOfBirth("year(int)", "month(int)", "day(int)");
BrazeBinding.SetUserCountry("country name");
BrazeBinding.SetUserHomeCity("city name");
BrazeBinding.SetUserEmailNotificationSubscriptionType(AppboyNotificationSubscriptionType);
BrazeBinding.SetUserPushNotificationSubscriptionType(AppboyNotificationSubscriptionType);
BrazeBinding.SetUserPhoneNumber("phone number");
デフォルト属性の解除
デフォルトのユーザー属性を解除するには、関連するメソッドにnullを渡します。
BrazeBinding.SetUserFirstName(null);
カスタムユーザー属性
デフォルトのユーザー属性に加え、Brazeではいくつかのデータタイプを使用してカスタム属性を定義することもできます。各属性のセグメンテーションオプションの詳細については、ユーザーデータ収集を参照してください。
カスタム属性の設定
カスタム属性を設定するには、属性タイプに対応するメソッドを使用します。
AppboyBinding.SetCustomUserAttribute("custom string attribute key", "string custom attribute");
// Set Integer Attribute
AppboyBinding.SetCustomUserAttribute("custom int attribute key", 'integer value');
// Increment Integer Attribute
AppboyBinding.IncrementCustomUserAttribute("key", increment(int))
AppboyBinding.SetCustomUserAttribute("custom float attribute key", 'float value');
AppboyBinding.SetCustomUserAttribute("custom boolean attribute key", 'boolean value');
AppboyBinding.SetCustomUserAttributeToNow("custom date attribute key");
AppboyBinding.SetCustomUserAttributeToSecondsFromEpoch("custom date attribute key", 'integer value');

Brazeに渡される日付は、ISO 8601形式(2013-07-16T19:20:30+01:00など)か、yyyy-MM-dd'T'HH:mm:ss:SSSZ形式(2016-12-14T13:32:31.601-0800など)でなければなりません。
// Setting An Array
AppboyBinding.SetCustomUserAttributeArray("key", array(List), sizeOfTheArray(int))
// Adding to an Array
AppboyBinding.AddToCustomUserAttributeArray("key", "Attribute")
// Removing an item from an Array
AppboyBinding.RemoveFromCustomUserAttributeArray("key", "Attribute")

カスタム属性値の最大長は255文字です。これより長い値は切り捨てられます。
カスタム属性の解除
カスタム属性を解除するには、UnsetCustomUserAttributeメソッドに関連する属性キーを渡します。
AppboyBinding.UnsetCustomUserAttribute("custom attribute key");
REST APIの使用
REST APIを使用して、ユーザー属性を設定または解除することもできます。詳細については、ユーザーデータエンドポイントを参照してください。
ユーザーサブスクリプションの設定
ユーザーのメールまたはプッシュサブスクリプションを設定するには、以下のいずれかの関数を呼び出します。
// Email notifications
AppboyBinding.SetUserEmailNotificationSubscriptionType()
// Push notifications
AppboyBinding.SetPushNotificationSubscriptionType()`
どちらの関数も引数としてAppboy.Models.AppboyNotificationSubscriptionTypeを取り、3つの異なるステータスがあります。
| サブスクリプションステータス | 定義 |
|---|---|
OPTED_IN |
購読中、かつ明示的にオプトイン済み |
SUBSCRIBED |
購読中、ただし明示的にオプトインしていない |
UNSUBSCRIBED |
配信停止済み、または明示的にオプトアウト済み、あるいはその両方 |

Windowsでは、ユーザーにプッシュ通知を送る際に明示的なオプトインは必要ありません。ユーザーがプッシュ登録されると、デフォルトでOPTED_INではなくSUBSCRIBEDに設定されます。詳細については、サブスクリプションと明示的なオプトインの実装に関するドキュメントを参照してください。
| サブスクリプションタイプ | 説明 |
|---|---|
EmailNotificationSubscriptionType |
有効なメールアドレスを受信すると、ユーザーは自動的にSUBSCRIBEDに設定されます。ただし、明示的なオプトインプロセスを確立し、ユーザーから明示的な同意を受け取った時点でこの値をOPTED_INに設定することをお勧めします。詳細については、ユーザーサブスクリプションの変更のドキュメントを参照してください。 |
PushNotificationSubscriptionType |
有効なプッシュ登録時に、ユーザーは自動的にSUBSCRIBEDに設定されます。ただし、明示的なオプトインプロセスを確立し、ユーザーから明示的な同意を受け取った時点でこの値をOPTED_INに設定することをお勧めします。詳細については、ユーザーサブスクリプションの変更のドキュメントを参照してください。 |

これらのタイプはAppboy.Models.AppboyNotificationSubscriptionTypeに属します。
メールサブスクリプションの設定
AppboyBinding.SetUserEmailNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN);
プッシュ通知サブスクリプションの設定
AppboyBinding.SetUserPushNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN);
前提条件
この機能を使う前に、React Native Braze SDKを統合する必要がある。
カスタム属性を記録する
Braze では、ユーザーに属性を割り当てるメソッドが提供されています。ダッシュボードでこれらの属性に基づき、ユーザーをフィルターおよびセグメント化できます。
デフォルトのユーザー属性
Brazeが自動的に収集するユーザー属性を設定するには、SDKに付属するセッターメソッドを使用できる。
1
Braze.setFirstName("Name");
以下の属性がサポートされています。
- 名
- 姓
- 性別
- 生年月日
- 市区町村
- 国
- 電話番号
- 言語
- メールアドレス
姓、名、国、市区町村などの文字列値はすべて255文字に制限されています。
カスタムユーザー属性
Braze は、定義済みのユーザー属性メソッドに加えて、アプリケーションからのデータを追跡するためのカスタム属性も提供しています。
Braze.setCustomUserAttribute("attribute_key", "attribute_value", function(){
// optional onResult callback
});
カスタム属性の設定解除
Braze.unsetCustomUserAttribute("attribute_key", function(){
// optional onResult callback
});
カスタム属性配列
// Adds a string to a custom attribute string array, or creates that array if one doesn't exist.
Braze.addToCustomUserAttributeArray("my-attribute-array", "new or existing value", optionalCallback);
// Removes a string from a custom attribute string array.
Braze.removeFromCustomUserAttributeArray("my-attribute-array", "existing value", optionalCallback);