You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Admin SDK推送通知无法统计数据,求解决方案或替代服务

Hey there! Let's tackle your problem step by step.

Why You Can't See Metrics in Firebase Console

First off, the reason you're not seeing open/engagement rates in the Firebase Console when using the Admin SDK is that messages sent directly via the SDK are treated as "raw" or "direct" sends—they don't automatically tie into Firebase's built-in campaign analytics.

To fix this, you need to add an analytics_label parameter when sending your notifications through the Admin SDK. This label tells Firebase to track the message under that specific tag, and you'll then be able to view its metrics in the Firebase Console's Messaging section, under the "Reports" tab. Here's a quick example of how to add it in Laravel using the Firebase Admin SDK:

$message = [
    'token' => $deviceToken,
    'notification' => [
        'title' => 'Your Notification Title',
        'body' => 'Your Notification Body',
    ],
    'analytics_label' => 'laravel_push_campaign', // This is the key!
];

$messaging = app('firebase.messaging');
$messaging->send($message);
Google APIs to Access Push Notification Metrics

Yes, there are Google APIs you can use to pull this data programmatically:

  • Firebase Analytics REST API: This lets you fetch raw event data like notification_received and notification_open which correspond to your delivery and open rates. You'll need to authenticate with a service account and query the API for events tied to your analytics_label or app ID.
  • Google Analytics 4 (GA4) API: Since Firebase Analytics is now integrated with GA4, you can use the GA4 Data API to build custom reports for your push notification performance. This is great if you want to combine push metrics with other user behavior data.
  • FCM Reporting API: While more limited, this API gives you aggregated delivery data (like successful sends, failures) for messages sent via the Admin SDK. It doesn't track opens directly, but pairs well with the Analytics API for full visibility.

For Laravel, you can use the official google/cloud-core package or wrap the API calls in a custom service class to fetch this data easily.

Alternative Services with Built-in Push Analytics

If you're looking for a more turnkey solution with marketing-focused analytics, here are some solid options that play well with Laravel:

  • OneSignal: The most popular choice for push notifications. It has a robust dashboard with real-time delivery, open, and click rates, plus features like user segmentation, A/B testing, and automated campaigns. Laravel has a community-maintained package that makes integration a breeze.
  • Pusher Beams: A reliable service with clean analytics and support for web, mobile, and even in-app notifications. It integrates seamlessly with Laravel via their official SDK, and you get detailed metrics on delivery success, opens, and user engagement.
  • Pushwoosh: Built specifically for push marketing, it offers advanced analytics like conversion tracking, retention metrics, and audience insights. They have a Laravel SDK and support for multi-channel campaigns (push, email, SMS).
  • Airship: Enterprise-grade solution with powerful automation and analytics tools. It's great if you need to scale push campaigns with deep user behavior tracking, though it's a bit more heavyweight than the others.

All these services handle the analytics out of the box, so you won't have to mess with API calls to get the data you need.

内容的提问来源于stack exchange,提问作者Kevin Dave

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 06:42:05