概要: iOSとAndroidの両プラットフォームのプッシュ通知キャンペーンの成功度を計測します。
重要!
社内で開発したプッシュ通知を実装されている広告主さまもいらっしゃいます。他のオウンドメディアと同様に、AppsFlyerを使用してプッシュ通知のパフォーマンスを測定すると、それらのコンバージョンもアトリビューションおよびレポートできます。
SDKの要件
プッシュ通知の計測には、アプリのコード内でSDKのAPIを呼び出す必要があります。
プッシュ通知に対応したSDKのバージョン:
- Android: v4.8.0以降
- iOS: v4.8.5以降
この機能を有効にするには、プッシュ通知をタップした後に起動されるすべてのアクティビティの on Create
メソッド内で sendPushNotificationData
メソッドを呼び出してください。
AppsFlyerLib.getInstance().sendPushNotificationData(this);
この機能を有効にするには、AppDelegate.m内で handlePushNotificationData
のメソッドを呼び出してください。
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [[AppsFlyerLib shared] handlePushNotification:userInfo]; }
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { AppsFlyerLib.shared().handlePushNotification(userInfo) }
プッシュ通知キャンペーンのセットアップ
AppsFlyerは、Google Cloud Messaging または Apple push notification を含む全てのベンダーのプッシュ通知キャンペーンの測定をサポートしています。プッシュ通知メッセージから発生したアプリ起動として定義されたコンバージョンは、AppsFlyerのリターゲティングダッシュボードに表示されます。
以下のパラメーターがプッシュ通知ペイロードに挿入されます。以下の例に示すように、これらのパラメーターは "af "オブジェクトに含まれる必要があります。
- C
- キャンペーン名
- is_retargeting=true
- このパラメーターによりリターゲティングキャンペーンと認識します
- pid
- プッシュ通知プロバイダーであるメディアソース
(例:mixpanel_int, urbanairship_int, swrve_int)
使用可能なパラメーターのリストはこちらからご確認ください。
注意
このソリューションは、プッシュプロバイダーに関係なく同様です。
プッシュ通知からのディープリンク処理の設定
addPushNotificationDeepLinkPath
のメソッドを使えば、プッシュ通知のペイロードからディープリンクに必要な情報を取得する方法を、柔軟なインターフェイス上で提供します。
デフォルトの設定では、AppsFlyerのSDK はプッシュ通知のJSON
ペイロード内で af
キーに紐付くディープリンクの値を検索します。プッシュ通知機能のプロバイダーの多くは、SDK側が追加の設定を行わないと解決できない独自の JSON
スキーマを使用します。
addPushNotificationDeepLinkPath
を使用すると、プッシュ通知の JSON ペイロードのどのキーをSDKがディープリンクの値に使用するかを設定できるようになります。
AppsFlyer SDK が想定する、デフォルトのプッシュ通知のJSONスキーマを使用しないプッシュ通知プロバイダーとアプリを連携する場合には、このメソッドを使用してください。
addPushNotificationDeepLinkPath
を呼び出すと、SDKは以下を検証します:
- 必要なキーがペイロード内に存在しているか
- そのキーに有効なOneLink URLが含まれているか
一般的な実装
addPushNotificationDeepLinkPath
の以下の呼び出しと
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link")
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"deeply", @"nested", @"deep_link"]]
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"])
それに紐付くシナリオを確認してください。
シナリオ1
プッシュ通知経由でアプリが起動され、以下のような構造のペイロードが含まれていたとします。
{
...
"deeply": {
"nested": {
"deep_link": "https://yourdeeplink2.onelink.me"
}
}
...
}
この場合、SDKはdeep_link
の値を抽出し、ディープリンクのフローを続行します。
シナリオ2
プッシュ通知経由でアプリが起動され、以下のような構造のペイロードが含まれていたとします。
{
...
"deeply": {
"nested": {
"banana": "https://yourdeeplink2.onelink.me"
}
}
...
}
この場合、呼び出しが実行されても、SDKはペイロード内にdeep_link
のキーを見つけることができず、結果、何も起きません。(=ディープリンクしない)
シナリオ3
プッシュ通知経由でアプリが起動され、以下のような構造のペイロードが含まれていたとします。
{
...
"deeply": {
"nested": {
"deep_link": "Corrupted url or regular string"
}
}
...
}
この場合、SDKはdeep_link
のキーを検出しますが、そのディープリンクの値は無効です。そのため、上記の呼び出しが実行されても何も起こりません。
高度な設定
複数のペイロード構造を設定するには、addPushNotificationDeepLinkPath
を複数回呼び出してください:
- 有効なディープリンクの値を与えた最初のコールが使用されます。
- 他の呼び出しは無視されます。
一致するペイロードの構造がない場合や、有効なOneLink URLがペイロード内に見つからなかった場合には、何も起こりません。
たとえば、以下のペイロードの場合に
{
...
"deeply": {
"nested": {
“deep_link”: “https://yourdeeplink2.onelink.me”
}
},
“this”: {
“is”: {
"banana": "phone"
}
}
...
}
addPushNotificationDeepLinkPath
を呼び出した場合です。
// this.is.deep_link key isn’t found - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "deep_link");
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "banana");
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
// this.is.deep_link key isn’t found - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "deep_link");
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "banana");
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
// this.is.deep_link key isn’t found - nothing happens
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"this", @"is", @"deep_link"]]
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"this", @"is", @"banana"]]
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"deeply", @"nested", @"deep_link"]]
// this.is.deep_link key isn’t found - nothing happens
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["this", "is", "deep_link"]);
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["this", "is", "banana"])
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"])
ペイロードの例
以下のOSおよびベンダー別のペイロード例のリストを参照してください。
APNSを介したiOSのペイロード:
ペイロードの例:
{{
"af":{
"c":"test_campaign",
"is_retargeting":"true",
"pid":"push_provider_int"
},
"aps":{
"alert":"Get 5000 Coins",
"badge":"37",
"sound":"default"
}
}}
Firebase Cloud MessagingでのAndroid / iOS向けペイロード
Firebase Cloud Messagingには、プッシュ通知を送信できる複数のAPIエンドポイントがあります。
-
Legacy HTTP Server Protocol - このAPIは、上記のデフォルトのペイロード構造を受け取ります。
"data":{{ "af":{ "pid":"braze_int", "is_retargeting":"true", "c":"test_campaign" } }}
-
HTTP V1 API - このAPIは、Legacy APIのようにネストされたオブジェクトを含むペイロードを受け入れません。正しいペイロード形式は、
af
オブジェクトを文字列 (string) 化する必要があります。
例:
"data": {{ "af": "{\"pid\":\"media_int\",\"is_retargeting\":\"true\", \"c\":\"test_campaign\"}" }}
-
Firebase Console UI - Firebase Console UIを使用してプッシュ通知を送信できます。ペイロードは最終段階で追加されます(追加オプション)。
カスタムデータの下で、af を Key として、ペイロードを Value として追加します。
次のスクリーンショットを参照ください。
{"pid":"MY_MEDIA_SOURCE","is_retargeting":"true","c":"test_campaign"}
その他のサードパーティベンダー
Airship API:
{
"audience":"all",
"notification":{
"alert":"A broadcast message",
"extra":{
"af":{
"pid":"urbanairship_int",
"is_retargeting":"true",
"c":"test_campaign"
}
}
},
"device_types":"ios"
}
詳しくは、 https://docs.airship.com/api/ua/をご覧ください。
Swrve API :
{{
"af":{
"pid":"swrve_int",
"is_retargeting":"true",
"c":"test_campaign"
}
}}
詳細:http://docs.swrve.com/user-documentation/push-notifications/creating-push-notifications/
Braze API :
{
"app_group_id":"getFromBrazeDashboard",
"segment_id":"getFromBrazeDashboard",
"broadcast":true,
"messages":{
"apple_push":{
"alert":"Alert A Message",
"title":"Not Visible, Yet Required",
"body":"Message Body",
"extra":{
"af":{
"pid":"braze_int",
"is_retargeting":"true",
"c":"test_campaign"
}
}
}
}
}
詳細: Braze push notifications API
Mixpanel API:
iOSの場合: https://mixpanel.com/help/reference/ios-push-notifications
Androidの場合: https://mixpanel.com/help/reference/android-push-notifications
Iterable API:
iOSの場合: https://support.iterable.com/hc/en-us/articles/115000315806
Androidの場合:https://support.iterable.com/hc/en-us/articles/115000331943
Localytics API:
iOSの場合: http://docs.localytics.com/dev/ios.html#push-messaging-ios
Androidの場合: http://docs.localytics.com/dev/android.html#push-messaging-android
Leanplum API:
参照: https://docs.leanplum.com/
Adobe Analytics (Omniture) API:
参照先: https://marketing.adobe.com/resources/help/en_US/mobile/t_create_push_message.html
Appoxee (Teradata) API:
参照先: https://appoxee-wiki.atlassian.net/wiki/display/MIC/Push+Message+API
Upsight API:
参照: http://help.upsight.com/push/
Accengage API:
iOSの場合: http://docs.accengage.com/display/IOS/iOS#iOS-Notificationscustomparameters
AppsFlyerリターゲティングソリューションの詳細については、次の記事を参照してください。