プッシュ通知を使ったリエンゲージメント・トラッキングのサポート
SingularはiOSアプリのリエンゲージメントを測定するためにプッシュ通知のトラッキングを可能にします。Apple Push Notification Service (APNs) とSingular SDKを統合することで、プッシュ通知によるユーザーインタラクションをトラッキングし、正確に属性化することができます。
以下の実装ガイドに従って、iOSアプリケーションのプッシュ通知を適切にトラッキングしましょう。
なぜプッシュ通知のトラッキングが重要なのか?
プッシュ通知はユーザーのリエンゲージメントに欠かせませんが、適切なトラッキングがなければその影響は不明です。Singularは通知インタラクションの適切な帰属を保証し、マーケティングキャンペーンの最適化とユーザーリテンションの測定を可能にします。
実装ガイド
ステップ 1: プッシュ通知の登録
UNUserNotificationCenter を使って、アプリがプッシュ通知に適切に登録されていることを確認します。
例
import UserNotifications
// Set the current instance as the delegate for the UNUserNotificationCenter to handle notifications
UNUserNotificationCenter.current().delegate = self
// Define the notification authorization options (alert, badge, sound)
let pushAuthOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
// Request notification authorization from the user
UNUserNotificationCenter.current().requestAuthorization(options: pushAuthOptions) { granted, error in
// If an error occurs during authorization, print the error description
if let error = error {
print("registerForPushNotifications : failure - \(error.localizedDescription)")
}
// If the user granted permission for notifications, register for remote notifications
if granted {
// Ensure that the registration for remote notifications is done on the main thread
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
- (void) registerForPushNotifications:(UIApplication *)application {
// Set delegate to self
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
// Define the push notification options
UNAuthorizationOptions pushAuthOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound;
// Request push notification authorization
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:pushAuthOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (error) {
NSLog(@"registerForPushNotifications : failure - %@", error.localizedDescription);
}
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[application registerForRemoteNotifications];
});
}
}];
}
このステップでは、アプリがプッシュ通知を受信して処理するように設定されていることを確認します。
ステップ2:プッシュ通知の処理とSingularへのデータ送信
プッシュ通知を受信したら、それを処理し、トラッキングのためにSingularに送信する必要があります。
例
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
// Pass the notification data to Singular for tracking.
Singular.handlePushNotification(response.notification.request.content.userInfo)
// Call the completion handler to indicate processing is complete.
completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
// Extract the push notification payload (user info).
NSDictionary *userInfo = response.notification.request.content.userInfo;
// Log the userInfo dictionary for debugging purposes.
NSLog(@"didReceiveNotificationResponse userInfo = %@", userInfo);
// Pass the notification data to Singular for tracking.
[Singular handlePushNotification:userInfo];
// Call the completion handler to indicate processing is complete.
completionHandler();
}
ステップ3:プッシュ通知ペイロードとSingular SDKの統合
Singular SDKがプッシュ通知を処理するように正しく設定されていることを確認します。
例
// Assuming config is an optional object, make sure it's not nil before using it
config?.pushNotificationLinkPath = [
["path", "to", "link"],["sng_link"]
]
// Start the Singular SDK with the given configuration (ensure config is valid)
Singular.start(config)
// Assuming config is already initialized and valid
config.pushNotificationLinkPath = @[
@[@"path", @"to", @"link"],
["sng_link"]
];
// Start the Singular SDK with the given configuration
[Singular start:config];
このステップにより、Singularはプッシュ通知のやりとりを正しく追跡し、それに応じて属性を設定することができます。
検証ガイド
Singular SDK APIコールは、開始セッションコールのsingular_link予約パラメータの下にプッシュ通知ペイロードリンクが正しく渡されることを確認します。
例
https://skan.singular.net:443/api/v1/start?dnt=-1&update_time=0&c=wwan&singular_link_resolve_required=false&rt=plist&lag=0.00&is=false&event_index=10&d=iPhone14,7&skan_has_framework=true&sdk=Singular/12.7.1&skan_conversion_value_mode=managed&mo=iPhone14,7&skan_update_counter=1&i=com.singular.SwiftScene&config_version=0&k=IDFV&cr=1&skan_total_admon_revenue_by_currency={}&install_time=1740577866&n=SwiftScene&av=1.0&skan_skadnetwork_enabled=true&p=iOS&idfv=D159BFDC-D061-479B-AB24-0CE00C1FA2AA&att_authorization_status=0&device_type=phone&s=F90C41BF-99EC-48FC-ABF8-2781FF5A2799&skan_first_call_to_skadnetwork_timestamp=1740577882&u=D159BFDC-D061-479B-AB24-0CE00C1FA2AA&skan_last_call_to_skadnetwork_timestamp=1740577882&singular_install_id=554DBBE4-9842-46A8-9F9D-24B8A9BF83E3&v=18.2.1&singular_link=https://sl.sng.link/Cclbu/2a7n_dl=com.singular.flutterApplication1&_smtype=3&singular_link_resolve_timeout=0&pu=1&a=sdk<>key&skan_total_revenue_by_currency={}&h=8aee646bc4b796a5f8908ef8af677ba0fde70aa9</>
代わりに、Singular SDK コンソールを使って、以下のようにDeeplink URL の下にあるプッシュ通知トラッキングリンクを確認することもできます。
これを確認することで、プッシュ通知のエンゲージメントがSingular SDK内で正しくトラッキングされていることを確認できます。
注意事項
- singularLinksHandler コードとは異なり、Singular SDK はこの機能のためのプッシュペイロードコールバックを提供していないことに注意してください。プッシュ通知データを読み取り、ユーザーをアプリ内の特定の商品ページにリダイレクトするディープリンクロジックを実装するのは、アプリ開発者の責任です。このソリューションでは、ユーザーが通知をタップするとSingularがプッシュ通知のペイロードを取得し、このペイロードをSingular.start() によってトリガーされるSDK開始セッションイベントに含めます。このデータはSingularのバックエンドで処理され、プッシュ通知のタッチポイント/クリックを属性化し、リエンゲージメント追跡のために登録されます。
-
プッシュ通知のペイロードに渡されたカスタムキー値のペアから、Singular のリンクドメインだけを許可する安全メカニズムがあります。具体的には、Singular Manage Linksページで事前に定義されたsng.linkドメインのみが許可されます。
例えば
https://prod_test.sng.link/B0s2a/51oi?_dl=singular%3A%2F%2Fmain
Singularリンクを別のドメイン(例:EメールサービスプロバイダのESPドメイン)でラップする場合は、セットアップで以下のオプションを追加して明示的にドメインを設定する必要があります:これにより、Singularフレームワーク内で外部ドメインが認識され、許可されます。以下の設定例を参照してください。config.espDomains = @[@"sl.esp.link"];
-
1つのプッシュ通知からユーザーのアクションに基づいて異なるディープリンクをトリガーする必要がある場合、1つのSingularトラッキングリンクを使用し、動的にリダイレクトを変更することができます。
例
ニュース速報のプッシュ通知は、複数のディープリンクオプションを提供することができます:
複数のトラッキングリンクを作成する代わりに、1つのSingularトラッキングリンクを設定し、ユーザーの選択に基づいて動的にリダイレクトを調整します。
最新ニュースを読む
トレンディングトピックス→(英語newsapp://article?id=12345
スポーツnewsapp://trending
newsapp://sports
以上の手順で、あなたのiOSアプリはSingularを使ってプッシュ通知をトラッキングするように設定されました。これにより、エンゲージメントのトラッキングが改善され、リエンゲージメントキャンペーンが最適化され、アトリビューションの精度が向上します。