Understanding message delivery

FCM provides tools to help you get insight into message delivery. In addition to the delivery reports and notification funnel analysis built into the Firebase console, FCM provides comprehensive data export to Google BigQuery.

Message delivery reports

You can evaluate whether the messages you send reach your users. In the Reports tab in the Firebase console, you can view the following data for messages sent to an FCM SDK, including those sent via the Notifications composer and the FCM APIs:

  • Sends — The data message or notification message has been enqueued for delivery or has been successfully passed to a third-party service like APNs for delivery. See lifetime of a message for more information.
  • Impressions (available only for notification messages on Android devices) — The display notification has been displayed on the device.
  • Opens — The user opened the notification message.

You can set a date range for the data displayed, with the option to export to CSV.

Notification funnel analysis

A built-in Notifications funnel analysis shows you how your users respond to a particular notifications sent from the Firebase console, with data for:

  • Notifications sent — The message has been enqueued for delivery or has been successfully passed to a third-party service like APNs for delivery.
  • Notifications opened — The number of notifications opened.
  • The number of unique users who have triggered a conversion event, if one is defined.

To see the Notifications funnel analysis:

  1. In the Notifications composer, select the Notifications tab.
  2. Click on a completed or in progress message in the message list. An expanded view including a Funnel analysis is displayed.

Analytics reports update periodically, but there can be some delay between when a user opens the notification and when the event data is available in the console.

In addition to these reports under the Notifications tab, you can also build custom funnels in Analytics to visualize the completion rate of a sequence of steps in your app.

BigQuery data export

You can export your message data into BigQuery for further analysis. BigQuery allows you to analyze the data using BigQuery SQL, export it to another cloud provider, or use the data for your custom ML models. See Link BigQuery to Firebase for more information.

To get started, open the Notifications composer and select Link BigQuery at the bottom of the page. Alternatively, you can select Settings > Project Settings from the left navigation bar, then select Integrations > BigQuery > Link. This page displays FCM export options for all FCM-enabled apps in the project.

What data is exported to BigQuery?

The shema of the exported table is:

_PARTITIONTIME TIMESTAMP This pseudo column contains a timestamp for the start of the day (in UTC) in which the data was loaded. For the YYYYMMDD partition, this pseudo column contains the value TIMESTAMP('YYYY-MM-DD').
event_timestamp TIMESTAMP Event timestamp as recorded by the server
project_number INTEGER The project number identifies the project that sent the message
message_id STRING The message id identifies a single unique message
instance_id STRING The instance id of the app the message is sent to (when available)
message_type STRING The type of the message. Can be Notification message or Data message. Topic is used to identify the original message for a topic or campaign send; the subsequent messages is either a notification or data message.
sdk_platform STRING The platform of the recipient app
app_name STRING The package name for Android apps or the bundle id for iOS apps
collapse_key STRING The collapse key identifies a group of messages that can be collapsed. When a device is not connected, only the last message with a given collapse key is queued for eventual delivery
priority INTEGER The priority of the message. Valid values are "normal" and "high." On iOS, these correspond to APNs priorities 5 and 10
ttl INTEGER This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline
topic STRING The name of the topic to which a message was sent (when applicable)
bulk_id INTEGER The bulk ID identifies a group of related messages, such as a particular send to a topic
device_recently_active BOOLEAN This parameter is true if the device has connected recently
event STRING The type of the event. Possible values are:
  • MESSAGE_ACCEPTED: the message was received by the FCM server and the request is valid;
  • MESSAGE_DELIVERED: the message has been sent to the device;
  • MESSAGE_DELIVERED_ON_RECONNECT: the message was sent to the device when the device re-connected;
  • MISSING_REGISTRATIONS: the request was rejected due to a missing registration;
  • MESSAGE_EXPIRED: the message expired before the device connected and it could be delivered;
  • MESSAGE_DELAYED_DOZE: the message delivery to the device was being delayed because the device is in doze mode;
  • UNAUTHORIZED_REGISTRATION: the message was rejected because the sender is not authorized to send to the registration;
  • MESSAGE_COLLAPSED: the message was replaced by a newer message with the same collapse key before it could be delivered;
  • MESSAGE_RECEIVED_INTERNAL_ERROR: there was an unspecified error when processing the message request;
  • MESSAGE_DELAYED_THROTTLED:: the message delivery to the device was delayed due to throttling for its' collapse key;
  • MISMATCH_SENDER_ID: the request to send a message was rejected due to a mismatch between the sender id sending the message, and the one declared for the end-point;
  • QUOTA_EXCEEDED: the request to send a message was rejected due to insufficient quota;
  • INVALID_REGISTRATION: the request to send a message was rejected due to an invalid registration;
  • INVALID_PACKAGE_NAME: the request to send a message was rejected due to an invalid package name;
  • INVALID_APNS_CREDENTIAL: the request to send a message was rejected due to an invalid APNS certificate;
  • INVALID_PARAMETERS: the request to send a message was rejected due to invalid parameters;
  • PAYLOAD_TOO_LARGE: the request to send a message was rejected due to a payload larger than the limit;
  • DEVICE_NOT_FOUND: the request to send a message was rejected due to the device not being found in our database;
  • AUTHENTICATION_ERROR: the request to send a message was rejected due to an authentication error (check the API Key used to send the message);
  • INVALID_TTL: the request to send a message was rejected due to an invalid TTL.

What can you do with the exported data?

Count sent messages by app

SELECT app_name, COUNT(1)
FROM [<project name>:firebase_messaging.data]
WHERE
  _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
  AND event = 'MESSAGE_ACCEPTED'
  AND message_id != ''
GROUP BY 1;

Count unique app instances targeted by messages

SELECT COUNT(DISTINCT instance_id)
FROM [<project name>:firebase_messaging.data]
WHERE
  _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
  AND event = 'MESSAGE_ACCEPTED';

Count notification messages sent

SELECT COUNT(1)
FROM [<project name>:firebase_messaging.data]
WHERE
  _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
  AND event = 'MESSAGE_ACCEPTED'
  AND message_type = 'DISPLAY_NOTIFICATION';

Count data messages sent

SELECT COUNT(1)
FROM [<project name>:firebase_messaging.data]
WHERE
  _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
  AND event = 'MESSAGE_ACCEPTED'
  AND message_type = 'DATA_MESSAGE';

Count messages send to a topic or campaign from the notifications console

SELECT COUNT(1)
FROM [<project name>:firebase_messaging.data]
WHERE
  _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
  AND event = 'MESSAGE_ACCEPTED'
  AND bulk_id = <your bulk id> AND message_id != '';

Compute fanout duration for a given topic or campaign

The fanout start time is when the original request is received, and the end time is the time the last individual message targeting a single instance is created.

SELECT
  TIMESTAMP_DIFF(
    end_timestamp, start_timestamp, MILLISECOND
  ) AS fanout_duration_ms,
  end_timestamp,
  start_timestamp
FROM (
    SELECT MAX(event_timestamp) AS end_timestamp
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
      AND event = 'MESSAGE_ACCEPTED'
      AND bulk_id = <your bulk id>
  ) sent
  CROSS JOIN (
    SELECT event_timestamp AS start_timestamp
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
      AND event = 'MESSAGE_ACCEPTED'
      AND bulk_id = <your bulk id>
      AND message_type = 'TOPIC'
  ) initial_message;

Count percentage of delivered messages

SELECT
  messages_sent,
  messages_delivered,
  messages_delivered / messages_sent * 100 AS percent_delivered
FROM (
    SELECT COUNT(DISTINCT CONCAT(message_id, instance_id)) AS messages_sent
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
      AND event = 'MESSAGE_ACCEPTED'
  ) sent
  CROSS JOIN (
    SELECT COUNT(DISTINCT CONCAT(message_id, instance_id)) AS messages_delivered
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
      AND (event = 'MESSAGE_DELIVERED' OR event = 'MESSAGE_DELIVERED_ON_RECONNECT')
      AND message_id
      IN (
        SELECT message_id FROM [<project name>:firebase_messaging.data]
        WHERE
          _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
          AND event = 'MESSAGE_ACCEPTED'
        GROUP BY 1
      )
  ) delivered;

Track all events for a given message id and instance id

SELECT *
FROM [<project name>:firebase_messaging.data]
WHERE
    _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
    AND message_id = '<your message id>'
    AND instance_id = '<your instance id>'
ORDER BY event_timestamp;

Compute latency for a given message id and instance id

SELECT
  TIMESTAMP_DIFF(
    MAX(delivered_time), MIN(accepted_time), MILLISECOND
  ) AS latency_ms
FROM (
    SELECT event_timestamp AS accepted_time
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>')
      AND message_id = '<your message id>'
      AND instance_id = '<your instance id>'
      AND event = 'MESSAGE_ACCEPTED'
  ) sent
  CROSS JOIN (
    SELECT event_timestamp AS delivered_time
    FROM [<project name>:firebase_messaging.data]
    WHERE
      _PARTITIONTIME = TIMESTAMP('<date as YYYY-MM-DD>') AND
      message_id = '<your message id>' AND instance_id = '<your instance id>'
      AND (event = 'MESSAGE_DELIVERED' OR event = 'MESSAGE_DELIVERED_ON_RECONNECT')
  ) delivered;

Send feedback about...

Need help? Visit our support page.