AndroidおよびSwift/iOS向けのTealiumリモートコマンドによるBraze連携。
要件
- Braze APIキー
- 次のいずれかのモバイルライブラリ:
- Tealium for Android-Kotlin(1.0.0以降)
- Tealium for Android-Java(Braze 1.0.0以降の場合は5.9.0以降、以前のバージョンの場合は5.9.0未満)
- Tealium for iOS-Swift(2.8.0以降)
- 次のいずれかのリモートコマンド連携:
- BrazeリモートコマンドJSONファイル(Android-Kotlin 1.0.0以降またはiOS-Swift 2.1.0以降が必要)
- タグ管理のBrazeリモートコマンドタグ
仕組み
Braze連携では、次の項目を使用します。
- BrazeネイティブSDK。
- Brazeメソッドをラップするリモートコマンドモジュール。
- イベントトラッキングをBrazeのネイティブ呼び出しに変換するJSON構成ファイルまたはリモートコマンドタグ。
Brazeリモートコマンドモジュールをアプリに追加すると、必要なBrazeライブラリが自動的にインストールおよびビルドされるため、ベンダー固有のコードをアプリに追加する必要はありません。依存関係マネージャーを使用してインストールする場合、Braze SDKを別途インストールする必要はありません。
リモートコマンドには、JSON構成ファイルを使用する方法と、タグ管理を使用してマッピングを構成する方法の2つがあります。ベンダー連携には、リモートでホストするかアプリ内にローカルで配置したJSON構成ファイルの使用をお勧めします。タグ管理を使用する場合は、ベンダー連携用のリモートコマンドタグを追加します。ベンダー連携の詳細をご確認ください。
インストール
依存関係マネージャー
- Xcodeプロジェクトで、File > Add Packages… > Add Package Dependencyを選択します。
- リポジトリURLとして
https://github.com/tealium/tealium-ios-braze-remote-commandを入力します。 - バージョンルールを構成します。通常は
Up to next majorをお勧めします。現在のTealiumBrazeバージョンがリストに表示されない場合は、Swiftパッケージのキャッシュをリセットします。 - インストールする
TealiumBrazeモジュールを選択し、そのモジュールをインストールするアプリターゲットを選択します。
プロジェクトに複数のアプリターゲットがあり、追加のアプリターゲットでもTealiumBrazeモジュールが必要な場合は、Frameworks, Libraries, and Embedded Contentセクションでそれらを手動で追加する必要があります。
追加のアプリターゲットにTealiumBrazeをインストールするには、次の手順を実行します。
- Project NavigatorでXcodeプロジェクトを選択します。
- XcodeプロジェクトのTARGETSセクションでアプリターゲットを選択します。
- General > Frameworks, Libraries & Embedded Contentに移動し、
TealiumBrazeモジュールを選択してアプリターゲットに追加します。
Tealium Swiftライブラリから追加のモジュールを追加するには、Swift Package Managerの手順に従ってください。
Podfileに
tealium-swiftおよびpod "BrazeKit"が存在する場合は削除します。tealium-swiftの依存関係は、すでにTealiumBrazeフレームワークに含まれています。次の依存関係をPodfileに追加します。
pod "TealiumBraze"TealiumBrazePodには、次のTealiumSwift依存関係が含まれています。'tealium-swift/Core' 'tealium-swift/RemoteCommands'TealiumHelperファイル、およびTealiumクラスまたはBrazeリモートコマンドにアクセスするその他のファイルに、TealiumSwiftモジュールとTealiumBrazeモジュールをインポートします。
Cartfileから
tealium-swiftを削除します。tealium-swiftの依存関係は、すでにTealiumBrazeフレームワークに含まれています。Cartfileに次の依存関係を追加します。
github "tealium/tealium-ios-braze-remote-command"
Tealium for Android(Kotlin)またはTealium for Android(Java)をインストールし、まだ追加していない場合は、プロジェクトのトップレベルの
build.gradleファイルにTealium Maven URLを追加します。allprojects { repositories { mavenCentral() maven { url "https://maven.tealiumiq.com/android/releases/" } } }アプリプロジェクトの
build.gradleファイルに次の依存関係を追加して、Braze SDKとTealium-Brazeリモートコマンドの両方をインポートします。dependencies { implementation 'com.tealium.remotecommands:braze:3.0.0' implementation 'com.braze:android-sdk-ui:29.0.1' }
React Nativeプロジェクトのルートに移動します。
次のコマンドを使用して、
tealium-react-brazeパッケージをダウンロードしてインストールします。yarn add tealium-react-brazeReact Nativeの自動リンクはNPMパッケージのバージョン1.0.7で有効になっています。React Nativeバージョン0.60以降を使用している場合、
react-native linkを実行する必要はありません。
手動インストール
Brazeリモートコマンドを手動でインストールするには、Tealium for Swiftライブラリがインストールされている必要があります。iOSプロジェクトにBrazeリモートコマンドをインストールするには、次の手順を実行します。
まだインストールしていない場合は、Braze SDKをインストールします。
Tealium iOS Brazeリモートコマンドリポジトリをクローンし、
Sourcesフォルダー内のファイルをプロジェクトにドラッグします。remoteAPIEnabled構成フラグをtrueに構成します。
Brazeリモートコマンドを手動でインストールするには、Tealium for Android(Kotlin)またはTealium for Android(Java)がインストールされている必要があります。
AndroidプロジェクトにBrazeリモートコマンドをインストールするには、次の手順を実行します。
プロジェクトルートの
build.gradleファイルにflatDirを追加します。allprojects { repositories { mavenCentral() flatDir { dirs 'libs' } } }tealium-braze.aarを<PROJECT_ROOT>/<MODULE>/libsに追加します。build.gradleファイルにTealiumライブラリの依存関係を追加します。dependencies { implementation(name:'tealium-braze', ext:'aar') }
初期化
JSON 構成ファイルまたは Remote Command タグを使用して、Tealium の iOS(Swift)ライブラリ向けリモートコマンドを初期化します。
var tealium : Tealium?
let config = TealiumConfig(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
dataSource: "DATASOURCE")
config.dispatchers = [Dispatchers.TagManagement, Dispatchers.RemoteCommands]
config.remoteAPIEnabled = true // Required to use Remote Commands
tealium = Tealium(config: config) { _ in
guard let remoteCommands = self.tealium?.remoteCommands else {
return
}
// Webview Tag
let braze = BrazeRemoteCommand(brazeLocation: BrazeLocationProvider())
// Local JSON
//let braze = BrazeRemoteCommand(type: .local(file: "braze"), brazeLocation: BrazeLocationProvider())
// Remote JSON
//let braze = BrazeRemoteCommand(type: .remote(url: "https://some.domain.com/braze.json"), brazeLocation: BrazeLocationProvider())
remoteCommands.add(braze)
}
JSON 構成ファイルまたは Remote Command タグを使用して、Tealium の Kotlin ライブラリ向けリモートコマンドを初期化します。
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
Environment.DEV,
dispatchers = mutableSetOf(Dispatchers.RemoteCommands, Dispatchers.TagManagement));
// New code to add the Braze Remote Command
val braze = BrazeRemoteCommand(application,
true,
sessionHandlingBlacklist,
true,
inAppMessageBlacklist)
var tealium = Tealium.create(TEALIUM_MAIN, config) {
// Optional: Set config options that may not be supported yet by the Tag in Tag Management
// or simply to override settings locally.
braze.registerConfigOverride { builder ->
// builder.setIsLocationCollectionEnabled(true);
// builder.setGeofencesEnabled(true);
// builder.setPushDeepLinkBackStackActivityEnabled(true);
// builder.setPushDeepLinkBackStackActivityClass(UserActivity.class);
}
// register the command
// Webview Tag
remoteCommands?.add(braze);
// Local JSON
//remoteCommands?.add(braze, filename = "braze.json");
// Remote JSON
//remoteCommands?.add(braze, remoteUrl = "https://some.domain.com/braze.json");
}
Remote Command タグを使用して、Tealium の Android(Java)ライブラリ向けリモートコマンドを初期化します。
import com.tealium.remotecommands.BrazeRemoteCommand;
Tealium.Config config = Tealium.Config.create(application, "ACCOUNT", "PROFILE", "ENVIRONMENT");
Tealium teal = Tealium.createInstance(TEALIUM_MAIN, config);
BrazeRemoteCommand braze;
// Initialize with default configuration options.
braze = new BrazeRemoteCommand(config);
// Or alternatively initialize with some additional config options:
Set<Class> sessionHandlingBlacklist = new HashSet<>();
Set<Class> inAppMessageBlacklist = new HashSet<>();
// sessionHandlingBlacklist.add(MainActivity.class);
// inAppMessageBlacklist.add(UserActivity.class);
braze = new BrazeRemoteCommand(config,
true, // sessiongHandlingEnabled
sessionHandlingBlacklist, // sessionHandlingBlacklist
true, // registerInAppMessageManager
inAppMessageBlacklist); // inAppMessageBlackList
// Optional: Set config options that may not be supported yet by the Tag in Tag Management
// or simply to override settings locally.
braze.registerConfigOverride(new BrazeRemoteCommand.ConfigOverrider() {
@Override
public void onOverride(AppboyConfig.Builder b) {
b.setPushDeepLinkBackStackActivityEnabled(true);
b.setPushDeepLinkBackStackActivityClass(UserActivity.class);
}
});
// register the command
teal.addRemoteCommand(braze);
JSON 構成ファイルまたは Remote Command タグを使用して、React Native 向けリモートコマンドを初期化します。
import BrazeRemoteCommand from 'tealium-react-braze';
BrazeRemoteCommand.initialize();
// Webview Tag
let braze = { id: BrazeRemoteCommand.name }
// Local JSON
//let braze = { id: BrazeRemoteCommand.name, path: "braze.json" }
// Remote JSON
//let braze = { id: BrazeRemoteCommand.name, url: "https://some.domain.com/braze.json" }
let config = TealiumConfig {
// ...
remoteCommands: [braze]
}
JSON テンプレート
JSON 構成ファイルを使用してリモートコマンドを構成する場合は、以下のテンプレートを参照して作業を開始してください。このテンプレートには、標準的な e コマース実装で使用される一般的なマッピングが含まれています。必要に応じてマッピングを編集してください。
{
"config": {
"api_key": "YOUR_API_KEY",
"custom_endpoint": "sdk.iad-01.braze.com",
"session_timeout": 30,
"trigger_interval_seconds": 100,
"enable_geofences": true,
"enable_automatic_geofences": true,
"enable_automatic_location": true,
"push_story_identifier": "YOUR_IDENTIFIER",
"use_uuid_as_device_id": true,
"forward_universal_links": true
},
"mappings": {
"customer_id": "user_id",
"customer_first_name": "first_name",
"customer_last_name": "last_name",
"customer_gender": "gender",
"customer_language": "language",
"customer_email": "email",
"customer_home_city": "home_city",
"customer_dob": "date_of_birth",
"customer_alias": "user_alias",
"customer_alias_label": "alias_label",
"pet": "set_custom_attribute.pet",
"pet_count": "set_custom_attribute.pet_count",
"pet_count_unset": "unset_custom_attribute.pet_count_unset",
"pet_count_increment": "increment_custom_attribute.pet_count_increment",
"pet_names": "set_custom_array_attribute.pet_names",
"pet_names_append": "append_custom_array_attribute.pet_names_append",
"pet_names_remove": "remove_custom_array_attribute.pet_names_remove",
"screen_name": "screen_name",
"email_notification": "email_notification",
"push_notification": "push_notification",
"event_name": "event_name",
"current_level": "event.current_level",
"start_date": "event.start_date",
"high_score": "event.high_score",
"product_id": "product_id",
"product_quantity": "product_qty",
"product_unit_price": "product_unit_price",
"currency_code": "product_currency",
"rewards_member": "purchase.rewards_member",
"rewards_points_earned": "purchase.rewards_points_earned",
"date_joined_program": "purchase.date_joined_program",
"latitude": "location_latitude",
"longitude": "location_longitude",
"horizontal_accuracy": "location_horizontal_accuracy",
"vertical_accuracy": "location_vertical_accuracy"
},
"commands": {
"launch": "initialize",
"setengagement": "emailnotification,pushnotification",
"log_custom_event": "logcustomevent",
"set_location": "setlastknownlocation",
"custom_attribute": "setcustomattribute",
"unset_custom_attribute": "unsetcustomattribute",
"custom_array_attribute": "appendcustomarrayattribute",
"append_custom_array_attribute": "appendcustomarrayattribute",
"remove_custom_array_attribute": "removecustomarrayattribute",
"increment_custom_attribute": "incrementcustomattribute",
"log_purchase": "logpurchase",
"user_attribute": "userattribute,useridentifier,useralias",
"user_login": "useridentifier,useralias",
"user_alias": "useralias",
}
}
サポートされているメソッド
各 Braze メソッドにコマンドを対応付けます。Braze メソッドをトリガーするには、対応するコマンドを指定された形式で渡します。
| リモートコマンド | Braze メソッド |
|---|---|
addtosubscriptiongroup | user.addToSubscriptionGroup(id:) |
appendcustomarrayattribute | user.addToCustomAttributeArray() |
emailnotification | user.set(emailSubscriptionState:) |
enablesdk | enabled = true/false |
flush | requestImmediateDataFlush() |
incrementcustomattribute | user.incrementCustomUserAttribute() |
initialize | Braze(configuration:) |
logcustomevent | logCustomEvent() |
logpurchase | logPurchase() |
pushnotification | user.set(pushNotificationSubscriptionState:) |
removefromsubscriptiongroup | user.removeFromSubscriptionGroup(id:) |
removecustomarrayattribute | user.removeFromCustomAttributeArray() |
setadtrackingenabled | set(adTrackingEnabled:) |
setcustomattribute | user.setCustomAttribute()) |
setcustomarrayattribute | user.setCustomAttributeArray() |
setlastknownlocation | user.setLastKnownLocation() |
setsdkauthsignature | set(sdkAuthenticationSignature:) |
useralias | user.add(alias:) |
unsetcustomattribute | user.unsetCustomAttribute() |
userattribute | user.set() |
useridentifier | changeUser() |
wipedata | wipeData() |
Braze SDK は Tealium SDK とともにインストールされるため、対応するタグ構成を指定することで、Braze のネイティブ機能をトリガーできます。
SDK のセットアップ
初期化
Braze API キーとカスタムエンドポイントは必須であり、タグ構成で指定する必要があります。
| リモートコマンド | Braze メソッド(iOS) | Braze メソッド(Android) |
|---|---|---|
initialize | Braze(configuration:) | configure() |
起動オプションの構成には、以下のマッピングを使用します。
| パラメータ | 型 | 説明 |
|---|---|---|
api_key(必須) | String | API キーを構成します |
custom_endpoint(必須) | String | カスタム API エンドポイントを構成します。これは sdk.api.braze.eu 形式で送信されます |
device_options | [String] | Braze SDK が収集するデバイスフィールドの許可リストです(デフォルトでは、すべてのフィールドが収集されます)。 |
enable_automatic_geofences | Bool | ジオフェンスの自動収集を有効にします(true または false)。 |
enable_automatic_location | Bool | 位置情報の収集を有効にします(true または false)。 |
enable_geofences | Bool | ジオフェンスの収集を有効にします(true または false)。 |
flush_interval | Double | データのフラッシュ間隔を秒単位で構成します。値は NSTimeInterval に変換され、1.0 より大きくなければなりません。 |
is_sdk_authentication_enabled | Bool | SDK 認証を有効にします。デフォルトは false です。 |
push_story_identifier | String | Push Story Notification Content 拡張機能のアプリグループ名を表す文字列値を、このキーに構成します。 |
request_processing_policy | String | SDK のリクエスト処理に指定できる値です(manual または automatic)。デフォルトは automatic です。 |
session_timeout | Int(秒) | セッションタイムアウトの秒数です(デフォルトは 30 秒)。 |
trigger_interval_seconds | Int(秒) | アプリ内メッセージのトリガー間の最小間隔を上書きします(デフォルトは 30 秒)。 |
use_uuid_as_device_id | Bool | (iOS)ランダムに生成された UUID をデバイス ID として使用するかどうかを決定します(デフォルトは true)。 |
forward_universal_links | Bool | SDK がユニバーサルリンクを自動的に認識し、システムメソッドに転送するかどうかを指定します(デフォルトは false)。 |
Android
iOS
- Braze 開発者ガイド:SDK 起動時の Braze のカスタマイズ
- Braze 開発者ガイド:ネットワークトラフィックの詳細な制御
- Braze 開発者ガイド:位置情報とジオフェンス
- Braze 開発者ガイド:Push Story のセットアップ
- Braze 開発者ガイド:セッションの追跡
SDK 認証署名の構成
| リモートコマンド | Braze メソッド(iOS) | Braze メソッド(Android) |
|---|---|---|
setsdkauthsignature | set(sdkAuthenticationSignature:) | setSdkAuthenticationSignature |
| パラメータ | 型 |
|---|---|
sdk_authentication_signature | String |
フラッシュ
| リモートコマンド | Braze メソッド |
|---|---|
flush | requestImmediateDataFlush |
- Braze 開発者ガイド:分析の無効化
ユーザーの追跡
ユーザー ID の割り当て
| リモートコマンド | Braze メソッド |
|---|---|
useridentifier | changeUser |
| パラメータ | 型 |
|---|---|
user_id(必須) | String |
sdk_authentication_signature | String |
ユーザーのエイリアス構成
| リモートコマンド | Braze メソッド |
|---|---|
useralias | user.add(alias:) |
| パラメータ | 型 |
|---|---|
user_alias(必須) | String |
alias_label(必須) | String |
ユーザー属性
標準属性
| イベント | Braze メソッド |
|---|---|
| userattribute | Braze.User オブジェクトのフィールドを構成 |
| パラメータ | 型 |
|---|---|
first_name | String |
last_name | String |
email | String |
date_of_birth | String |
country | String |
language | String |
home_city | String |
phone | String |
gender | String |
- Braze 開発者ガイド:分析用ユーザー属性
- Braze 開発者ガイド:ユーザーデータ API
カスタム属性の構成
| リモートコマンド | Braze メソッド |
|---|---|
setcustomattribute | user.setCustomAttribute |
| パラメータ | 型 |
|---|---|
set_custom_attribute.PROPERTY | [String: Any] / JSONObject |
カスタム属性の構成解除
| リモートコマンド | Brazeメソッド |
|---|---|
setcustomattribute | user.unsetCustomAttribute |
| パラメーター | 型 |
|---|---|
set_custom_attribute.PROPERTY | String |
カスタム属性のインクリメント
| リモートコマンド | Brazeメソッド |
|---|---|
incrementcustomattribute | user.incrementCustomUserAttribute |
| パラメーター | 型 |
|---|---|
increment_custom_attribute.PROPERTY | String |
カスタム配列属性の構成
| リモートコマンド | Brazeメソッド |
|---|---|
setcustomarrayattribute | user.setCustomAttributeArray |
| パラメーター | 型 |
|---|---|
set_custom_array_attribute.PROPERTY | [String: [Any]] / JSONObject |
カスタム配列属性への追加
| リモートコマンド | Brazeメソッド |
|---|---|
appendcustomarrayattribute | user.addToCustomAttributeArray |
| パラメーター | 型 |
|---|---|
append_custom_array_attribute.PROPERTY | [String: String] / JSONObject |
カスタム配列属性からの削除
| リモートコマンド | Brazeメソッド |
|---|---|
removecustomarrayattribute | user.removeFromCustomAttributeArray |
| パラメーター | 型 |
|---|---|
remove_custom_array_attribute.PROPERTY | [String: String] / JSONObject |
カスタムイベントのトラッキング
カスタムイベント
| リモートコマンド | Brazeメソッド |
|---|---|
logcustomevent | logCustomEvent |
| パラメーター | 型 |
|---|---|
event_name(必須) | String |
event_properties | [String: Any] / JSONObject |
通知
メール通知
| リモートコマンド | Brazeメソッド |
|---|---|
emailnotification | setEmailNotificationSubscriptionType |
| パラメーター | 型 | 例 |
|---|---|---|
email_notification | String | ["optedin", "subscribed", "unsubscribed"] |
サブスクリプショングループへの追加
| リモートコマンド | Brazeメソッド |
|---|---|
addtosubscriptiongroup | user.addToSubscriptionGroup(id:) |
| パラメーター | 型 |
|---|---|
subscription_group_id(必須) | String |
サブスクリプショングループからの削除
| リモートコマンド | Brazeメソッド |
|---|---|
removefromsubscriptiongroup | user.removeFromSubscriptionGroup(id:) |
| パラメーター | 型 |
|---|---|
subscription_group_id(必須) | String |
プッシュ通知
| リモートコマンド | Brazeメソッド |
|---|---|
pushnotification | setPushNotificationSubscriptionType |
| パラメーター | 型 | 例 |
|---|---|---|
push_notification | String | ["optedin", "subscribed", "unsubscribed"] |
購入のトラッキング
購入の記録
| リモートコマンド | Brazeメソッド |
|---|---|
logpurchase | logPurchase |
| パラメーター | 型 |
|---|---|
product_id(必須) | [String] / String[] |
product_currency(必須) | String / String |
price(必須) | [Double] / Double[] |
product_qty | [Int] / Int[] |
purchase_properties | [AnyHashable: Any] / JSONObject |
位置情報のトラッキング
ユーザーの最終既知位置の構成
| リモートコマンド | Brazeメソッド |
|---|---|
setlastknownlocation | user.setLastKnownLocation |
| パラメーター | 型 |
|---|---|
latitude(必須) | Double |
longitude(必須) | Double |
horizontalAccuracy(必須) | Double |
altitude | Double |
verticalAccuracy | Double |
データプライバシー(同意オプション)
SDKの有効化
| リモートコマンド | Brazeメソッド(iOS) | Brazeメソッド(Android) |
|---|---|---|
enablesdk | enabled | enableSdk |
SDKの無効化
| リモートコマンド | Brazeメソッド(iOS) | Brazeメソッド(Android) |
|---|---|---|
disablesdk | enabled | disableSdk |
データの消去
| リモートコマンド | Brazeメソッド |
|---|---|
wipedata | wipeData |
広告トラッキングの有効化構成
| リモートコマンド | Brazeメソッド |
|---|---|
setadtrackingenabled | set(adTrackingEnabled:) |
| パラメータ | 型 |
|---|---|
ad_tracking_enabled(必須) | Bool |
Brazeインスタンスへのアクセス(iOS)
リモートコマンドを使用すると、イベントや購入の記録など、Brazeが提供する一部の機能をアプリに簡単にマッピングできます。
ただし、コンテンツカード、機能フラグ、通知など、一部のBraze機能については、Brazeインスタンスを使用してアプリに統合する必要があります。
Brazeインスタンスに直接アクセスするには、onReadyメソッドを使用します。onReadyメソッドは、Brazeインスタンスが正しく構成されると、完了ブロックでそのインスタンスを返します。
brazeRemoteCommand.onReady { braze in
// use the Braze instance here
}
Brazeインスタンスへの参照を取得したら、Brazeのドキュメントに記載されているとおりに使用してください。
プッシュ通知の自動統合
最新バージョンのBrazeでは、リモート通知の処理を自動化できます。詳細については、Braze開発者ガイド:プッシュ通知の自動統合を参照してください。
この機能を使用するには、アプリデリゲートのdidFinishLaunchingWithOptionsメソッド内で、メインスレッド上でBrazeインスタンスを同期的に初期化する必要があります。そのため、リモートコマンド構成を使用する代わりに、Brazeインスタンスを直接構成する必要があります。
Brazeインスタンスを直接構成するには、次のコードを使用します。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let brazeConfig = Braze.Configuration(apiKey: "YOUR_API_KEY", endpoint: "YOUR_ENDPOINT")
brazeConfig.push.automation = true
// ...
// add all your other configuration here
// ...
let brazeInstanceWrapper = BrazeInstance()
brazeInstanceWrapper.initializeBraze(brazeConfig: brazeConfig)
let brazeCommand = BrazeRemoteCommand(brazeInstance: brazeInstanceWrapper)
let tealiumConfig = TealiumConfig(...)
tealiumConfig.remoteCommands = [brazeCommand]
// ...
// complete tealium initialization
return true
}
プッシュ通知の手動統合
プッシュ通知の手動統合を実装するには、リモートコマンド構成を維持したまま、Brazeインスタンスに直接アクセスしてプッシュ通知の統合を有効にします。
詳細については、Braze開発者ガイド:プッシュ通知の手動統合を参照してください。
最終更新日 :: 2026年November月3日