AndroidおよびSwift/iOSにおけるAppsFlyerのTealiumリモートコマンド統合です。
要件
- AppsFlyer アプリ ID および デバイス キー
- これらのモバイル ライブラリのうちのいずれか:
- Tealium for Android-Kotlin (1.0.0 以降)
- Tealium for Android-Java (5.9.0 以降 (AppsFlyer 1.0.0 以降用) または 5.9.0 以前 (旧バージョン用))
- Tealium for iOS-Swift
- これらのリモート コマンド統合のいずれか:
- AppsFlyer Remote Command JSON File (Android-Kotlin 1.0.0 以降または iOS-Swift 2.1.0 以降が必要)
- AppsFlyerリモート コマンド タグ (Tealium iQ タグ管理)
仕組み
AppsFlyer 統合は、これらのアイテムを使用します:
- AppsFlyer ネイティブ SDK
- AppsFlyer メソッドをラップするリモート コマンド モジュール
- イベント トラッキングをネイティブ AppsFlyer コールに翻訳する、JSON 構成ファイルまたは Remote Command タグのいずれか
AppsFlyer リモート コマンド モジュールをアプリに追加すると、必要な AppsFlyer ライブラリが自動的にインストールされ、ビルドされます。この際、ベンダー固有のコードをアプリに追加する必要はありません。依存関係マネージャのインストールを使用している場合、AppsFlyer SDKを個別にインストールする必要はありません。
リモート コマンド オプションは、次の 2 つがあります: A JSON 構成ファイル、または、マッピングを構成するための iQ タグ管理の使用。A JSON 構成ファイルは、リモートでホスティングするか、またはアプリ内でローカルでホスティングするかのいずれでも、ベンダー統合の推奨オプションです。iQ タグ管理を使用する場合は、ベンダー統合用のリモート コマンド タグを追加します。ベンダー統合の詳細は、こちらから参照してください。
iOS:AppsFlyerバージョン4.8.11以降の場合、SDKはネイティブフレームワークAdSupport.frameworkおよびiAd.frameworkを自動的に追加します。詳細については、AppsFlyer iOS SDK統合に関するガイドを参照してください。
インストール
依存関係マネージャ
次の依存関係マネージャのいずれかをインストールに使用することをお勧めします。
CocoaPodsを使用してiOSのAppsFlyerリモートコマンドをインストールするには:
tealium-swiftとpod "AppsFlyerFramework"がPodfileに存在する場合は削除します。tealium-swiftの依存関係はTealiumAppsFlyerフレームワークに既に含まれています。次の依存関係をPodfileに追加します。
pod "TealiumAppsFlyer"
TealiumAppsFlyerポッドには以下のTealiumSwift依存関係が含まれています。
'tealium-swift/Core'
'tealium-swift/RemoteCommands'
'tealium-swift/TagManagement'
- モジュール
TealiumSwiftおよびTealiumAppsFlyerを、TealiumHelperファイル、Tealiumクラスにアクセスするその他のファイル、またはAppsFlyerリモートコマンドにインポートします。
Carthageを使用してiOSのAppsFlyerリモートコマンドをインストールするには:
tealium-swiftをCartfileから削除します。tealium-swiftの依存関係はTealiumAppsFlyerフレームワークに既に含まれています。以下の行がCartfileに存在する場合は、その行を削除します。
`binary "https://raw.githubusercontent.com/AppsFlyerSDK/AppsFlyerFramework/master/AppsFlyerLib.json"`
- 次の依存関係をCartfileに追加します。
github "tealium/tealium-ios-appsflyer-remote-command"
Tealium for Swift SDK (バージョン 1.x) および TealiumAppsFlyer バージョン 1.x では、 TealiumDelegate モジュールがインストールに含まれている必要があります。
Mavenを使用してAndroidのAppsFlyerリモートコマンドをインストールするには:
Tealium for Android (Kotlin) または Tealium for Android (Java) をインストールして、Tealium Maven URL を、プロジェクトのトップレベル
build.gradleファイルに追加します (まだ済んでいない場合)。allprojects { repositories { mavenCentral() maven { url "https://maven.tealiumiq.com/android/releases/" } } }アプリプロジェクトの
build.gradleファイルに次の依存関係を追加して、AppsFlyer SDKとTealium-AppsFlyerの両方のリモートコマンドをインポートします。
dependencies {
implementation 'com.tealium.remotecommands:appsflyer:1.0.0'
}
手動による手順(iOS)
AppsFlyer リモート コマンドを手動でインストールするには、 Tealium for Swift ライブラリがインストールされている必要があります。iOSプロジェクトのAppsFlyerリモートコマンドをインストールするには:
AppsFlyer SDKをまだインストールしていない場合はインストールします。
Tealium iOS AppsFlyerリモートコマンドレポジトリをクローンして、
Sourcesフォルダ内のファイルをプロジェクトにドラッグします。remoteAPIEnabled構成フラッグをtrueに構成します
手動(Android)
AppsFlyer リモート コマンドを手動でインストールするには、 Tealium for Android (Kotlin) または Tealium for Android (Java) がインストールされている必要があります。AndroidプロジェクトのAppsFlyerリモートコマンドをインストールするには:
flatDirをプロジェクトのルートにあるbuild.gradleファイルに追加します。
allprojects {
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
tealium-appsflyer.aarを<PROJECT_ROOT>/<MODULE>/libsに追加します。Tealiumライブラリの依存関係を
build.gradleファイルに追加します。
dependencies {
implementation(name:'tealium-appsflyer', ext:'aar')
}
初期化
すべてのTealiumライブラリについて、初期化時にAppsFlyerリモートコマンドを登録します。
Android (Kotlin)
Tealium の Android (Kotlin) ライブラリ用の JSON 構成ファイルまたはリモート コマンド タグを用いてリモート コマンドを初期化します。
以下のコードは、ローカル ファイル オプションを使用して、JSON Remote Command 機能とともに用いるために設計されています。
// Sets up a config object and creates a Tealium instance
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
Environment.DEV,
dispatchers = mutableSetOf(Dispatchers.RemoteCommands));
var tealium = Tealium.create(TEALIUM_MAIN, config) {
// New code to add the AppsFlyer Remote Command
val appsFlyerRemoteCommand = AppsFlyerRemoteCommand(application,
appsFlyerDevKey = devKey)
// register the command
remoteCommands?.add(appsFlyerRemoteCommand, filename = "appsflyer.json");
}
以下のコードは、Remote Command タグ機能とともに用いるために設計されています。
// Sets up a config object and creates a Tealium instance
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
Environment.DEV,
dispatchers = mutableSetOf(Dispatchers.RemoteCommands));
var tealium = Tealium.create(TEALIUM_MAIN, config) {
// New code to add the AppsFlyer Remote Command
val appsFlyer = AppsFlyerRemoteCommand(application,
appsFlyerDevKey = devKey)
// register the command
remoteCommands?.add(appsFlyer);
}
Android (Java)
Android 向けの JSON Remote Command ファイル機能は、Kotlin SDK でのみ利用できます。
以下のコードは、Remote Command タグ機能とともに用いるために設計されています。
// Sets up a config object and creates a Tealium instance
Tealium.Config config = Tealium.Config.create(application, "ACCOUNT", "PROFILE", "ENVIRONMENT");
Tealium teal = Tealium.createInstance(TEALIUM_MAIN, config);
// New code to add the AppsFlyer Remote Command
AppsFlyerRemoteCommand appsFlyer = new AppsFlyerRemoteCommand(application, appsFlyerDevKey = devKey)
teal.addRemoteCommand(appsFlyer);
iOS (Swift)
Tealium の iOS (Swift) ライブラリ用の JSON 構成ファイルまたはリモート コマンド タグを用いてリモート コマンドを初期化します。
以下のコードは、ローカル ファイル オプションを使用して、JSON Remote Command 機能とともに用いるために設計されています。
var tealium : Tealium?
let config = TealiumConfig(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
dataSource: "DATASOURCE",
optionalData: nil)
config.remoteAPIEnabled = true // Required to use Remote Commands
tealium = Tealium(config: config) { _ in
guard let remoteCommands = self.tealium?.remoteCommands else {
return
}
let appsflyer = AppsFlyerRemoteCommand(type: .local(file: "appsflyer"))
remoteCommands.add(appsflyer)
}
以下のコードは、Remote Command タグ機能とともに用いるために設計されています。
var tealium : Tealium?
let config = TealiumConfig(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
dataSource: "DATASOURCE",
optionalData: nil)
config.remoteAPIEnabled = true // Required to use Remote Commands
tealium = Tealium(config: config) { _ in
guard let remoteCommands = self.tealium?.remoteCommands else {
return
}
let appsFlyer = AppsFlyerRemoteCommand()
remoteCommands.add(appsFlyer)
}
プッシュメッセージトラッキング
Tealium Swiftライブラリには、Tealium と AppsFlyer リモート コマンドを介してプッシュ メッセージ トラッキングに対処するための TealiumRegistration プロトコルが含まれています。Tealium は ラッパー クラス AppsFlyerInstance でこのプロトコルに準拠し、プッシュ メッセージ認証イベントとプッシュ メッセージ オープン イベントの送信、およびトラッキングのアンインストールにこのプロトコルを使用しています。プッシュメッセージトラッキング機能を利用することをお勧めします。
iOSプロジェクトのプッシュメッセージトラッキングを統合するには、次の手順を実行します。
TealiumHelper.swiftファイルで、TealiumRegistrationプロトコルに準拠しているオブジェクトの空の配列を初期化します。例:
var pushMessagingTrackers = [TealiumRegistration]()
AppsFlyerRemoteCommandの前にAppsFlyerInstanceを初期化します- 前述の配列に
AppsFlyerInstanceを追加します
以下は、プッシュメッセージトラッキング統合の例の全文です。
var pushMessagingTrackers = [TealiumRegistration]()
var tealium : Tealium?
let config = TealiumConfig(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
dataSource: "DATASOURCE",
optionalData: nil)
config.remoteAPIEnabled = true // Required to use Remote Commands
tealium = Tealium(config: config) { _ in
guard let remoteCommands = self.tealium?.remoteCommands else {
return
}
let appsflyerInstance = AppsFlyerInstance()
let appsflyer = AppsFlyerRemoteCommand(appsflyerInstance: appsflyerInstance, type: .local(file: "appsflyer"))
pushMessagingTrackers.append(appsflyerInstance)
remoteCommands.add(appsflyer)
}
TealiumHelper.swiftファイル全体を表示するには、AppsFlyerリモートコマンドサンプルアプリを確認してください。ユーザーが通知の登録、プッシュメッセージのオープン、またはアプリのアンインストールを行った後でAppsFlyerにイベントを送信するには、ファイルAppDelegate.swiftを参照してください
AppsFlyerのプッシュメッセージ、およびトラッキング機能のアンインストールの詳細については、開発者向けiOS SDK統合に関するガイドを参照してください。
JSON テンプレート
JSON 構成ファイルを使用してリモート コマンドを構成しようとする場合は、まず、以下のテンプレートを参照します。テンプレートには、標準的な E コマースのインストールに用いられる共通マッピングが含まれます。必要に応じて、マッピングを編集します。
{
"config": {
"app_id": "YOUR_APP_ID",
"app_dev_key": "YOUR_APPSFLYER_DEV_KEY",
"settings": {
"custom_data": {"custom_key": "custom_value"},
"debug": true,
"disable_ad_tracking": false,
"disable_apple_ad_tracking": false,
"time_between_sessions": 30,
"anonymize_user": false,
"collect_device_name": false
}
},
"mappings": {
"latitude": "af_lat",
"longitude": "af_long",
"customer_email": "customer_emails",
"hash_type": "email_hash_type",
"currency_code": "af_currency",
"customer_id": "af_customer_user_id",
"signup_method": "event.signup_method",
"achievement_id": "event.achievement_id",
"checkout_option": "event.checkout_option",
"checkout_step": "event.checkout_step",
"content": "event.content",
"content_type": "event.content_type",
"coupon": "event.coupon",
"product_brand": "event.product_brand",
"product_category": "event.product_category",
"product_id": "event.af_content_id",
"product_list": "event.product_list",
"product_location_id": "event.product_location_id",
"product_name": "event.product_name",
"product_variant": "event.product_variant",
"product_unit_price": "event.af_price",
"product_quantity": "event.af_quantity",
"current_level": "event.level",
"score": "event.score",
"search_keyword": "event.search_keyword",
"order_shipping_amount": "event.order_shipping",
"order_tax_amount": "event.order_tax",
"order_id": "event.af_order_id",
"order_total": "event.af_revenue",
"currency_type": "event.currency_type",
},
"commands": {
"launch": "initialize,launch",
"geofence_entered": "tracklocation",
"geofence_exited": "tracklocation",
"user_login": "login",
"user_register": "setuseremails,setcustomerid,completeregistration",
"show_offers": "adclick",
"cart_add": "addtocart",
"wishlist_add": "addtowishlist",
"payment": "addpaymentinfo",
"unlock_achievement": "unlockachievement",
"level_up": "achievelevel,customersegment",
"email_signup": "subscribe",
"product": "viewedcontent",
"category": "listview",
"share": "share",
"search": "search",
"checkout": "initiatecheckout",
"order":"purchase"
}
}
サポートされているメソッド
以下のAppsFlyerメソッドは、以下のTealiumコマンドを使用し、AppsFlyerリモートコマンドタグのデータマッピングを使用してトリガーできます。
| リモートコマンド | AppsFlyerメソッド |
|---|---|
initialize | initialize() |
trackLaunch | trackLaunch() |
| 以下のいずれかのイベント名 | trackEvent() |
setHost | setHost() |
setUserEmails | setUserEmails() |
setCurrencyCode | currencyCode (property on the AppsFlyerTracker.shared object) |
setCustomerId | customerUserID (property on the AppsFlyerTracker.shared object) |
disableDeviceTracking | setDeviceTrackingDisabled |
disableTracking | isStopTracking (property on the AppsFlyerTracker.shared object) |
resolveDeeplinkUrls | resolveDeepLinkURLs (property on the AppsFlyerTracker.shared object) |
didReceiveRemoteNotification内のAppDelegateで手動で呼び出されます | handlePushNotification() |
didReceiveRemoteNotification内のAppDelegateで手動で呼び出されます | trackEvent() - event name: af_opened_from_push_notification |
didRegisterForRemoteNotificationsWithDeviceToken内のAppDelegateで手動で呼び出されます | registerPushToken() |
標準イベント名
以下は、trackEventメソッドでサポートされている標準イベント名のリストです。以下のコマンド名のいずれかが送信された場合は、AppsFlyer SDKで自動的にトリガーされます。ここでは、その特定のイベントに対する必要なすべての変数のマッピングおよび定義も行われていることが前提となっています。アプリ内イベントの記録に関する詳細と、推奨される業種別アプリ内イベントのリストをご確認ください。
| リモートコマンド | AppsFlyerイベント名 |
|---|---|
achievedLevel | "af_level_achieved" |
addPaymentInfo | "af_add_payment_info" |
addToCart | "af_add_to_cart" |
addToWishlist | "af_add_to_wishlist" |
completeRegistration | "af_complete_registration" |
completeTutorial | "af_tutorial_completion" |
initiateCheckout | "af_initiated_checkout" |
purchase | "af_purchase" |
subscribe | "af_subscribe" |
startTrial | "af_start_trial" |
rate | "af_rate" |
search | "af_search" |
spentCredits | "af_spent_credits" |
unlockAchievement | "af_achievement_unlocked" |
contentView | "af_content_view" |
listView | "af_list_view" |
adClick | "af_ad_click" |
adView | "af_ad_view" |
travelBooking | "af_travel_booking" |
share | "af_share" |
invite | "af_invite" |
reEngage | "af_re_engage" |
update | "af_update" |
login | "af_login" |
customerSegment | "af_customer_segment" |
pushNotificationOpened | "af_opened_from_push_notification" |
AppsFlyer SDKはTealium SDKとともにインストールされるので、対応するタグ構成があれば任意のネイティブAppsFlyer機能をトリガーできます。
SDKのセットアップ
初期化
AppsFlyer SDKは起動時に自動的に初期化されます。AppsFlyer APIキーはタグ構成で構成されます。
| リモートコマンド | AppsFlyerメソッド |
|---|---|
initialize | initialize() |
AppsFlyer開発者ガイド:SDKの初期セットアップ
AppsFlyer リモート コマンド タグで構成できる構成オプションはいくつかあります。以下のいずれかが起動時に構成された場合は、初期化メソッドの実行中に送信されます。
構成オプション
| Name | iQ 変数マッピング | 型 |
|---|---|---|
debug | debug | Bool |
disableIAdTracking | disable_apple_ad_tracking | Bool |
minTimeBetweenSessions | time_between_sessions | Int |
anonymizeUser | anonymize_user | Bool |
shouldCollectDeviceName | collect_device_name | Bool |
customData | custom_data | DictionaryまたはMap |
AppsFlyer開発者ガイド:追加のAPI
起動のトラッキング
| リモートコマンド | AppsFlyerメソッド |
|---|---|
initialize or launch | trackLaunch() |
ライフサイクルモジュールがインストールされている場合、このイベントはすべてのアプリ起動を自動的に送信します。
AppsFlyer開発者ガイド:SDKの初期化
ロケーション
ロケーションのトラッキング
| リモートコマンド | AppsFlyerメソッド |
|---|---|
tracklocation | trackEvent() - イベント名af_location_coordinates |
| パラメータ | 型 |
|---|---|
latitude (required) | Bool |
longitude (required) | Bool |
ロケーションモジュールがインストールされている場合は、緯度と経度がすべてのイベントで送信されます。
AppsFlyer APIリファレンス:ロケーショントラッキング
その他のオプション
ホストの構成
| リモートコマンド | AppsFlyerメソッド |
|---|---|
sethost | setHost |
| パラメータ | 型 |
|---|---|
host (required) | String |
hostPrefix (required) | String |
AppsFlyer APIリファレンス:ホストの構成
ユーザーのEメールの構成
| リモートコマンド | AppsFlyerメソッド |
|---|---|
setsermails | setUserEmails |
| パラメータ | 型 |
|---|---|
emails (required) | [String] |
cryptType (required) | Int |
暗号タイプリファレンス
| 値 | 型 |
|---|---|
0 | None |
1 | SHA1 |
2 | MD5 |
3 | SHA256 |
AppsFlyer APIリファレンス:ユーザーのEメールの構成
通貨コードの構成
| リモートコマンド | AppsFlyerプロパティ |
|---|---|
setcurrencycode | currencyCode |
| パラメータ | 型 |
|---|---|
currency (required) | String |
AppsFlyer APIリファレンス:通貨コードの構成
顧客IDの構成
| リモートコマンド | AppsFlyerプロパティ |
|---|---|
setcustomerid | customerUserID |
| パラメータ | 型 |
|---|---|
customerId (required) | String |
ディープリンクURLの解決
| リモートコマンド | AppsFlyerプロパティ |
|---|---|
| resolvedeeplinkurls | resolveDeepLinkURLs |
| パラメータ | 型 |
|---|---|
deepLinkUrls (required) | [String] |
AppsFlyer APIリファレンス:ディープリンクURLの解決
トラッキングの無効化
| リモートコマンド | AppsFlyerプロパティ |
|---|---|
| disabletracking | isStopTracking |
| パラメータ | 型 |
|---|---|
stopTracking (required) | ブーリアン |
AppsFlyer追加のAPI:トラッキングの停止(オプトアウト)
最終更新日 :: 2024年November月6日