Collecting MoPub Impression-Level Data as a Firebase Event

Today MoPub doesn’t offer an API providing impression-level events. The information is only allowed as a post-back to the app.

One of the easiest ways to track MoPub impression-level data is by enabling Firebase to collect ad impressions as events. This article outlines the recommended methods for doing so.


  1. Enable ILRD

  2. Integrate listeners to collect the post-back

  3. Send the information as a Firebase Event.

1. Enabling Impression-level Revenue Data (ILRD):

First, data will only be sent to SDK versions v5.7.0 or higher.

Below is MoPub’s documentation on the latest versions:

Contact your MoPub account representative to enable ILRD. If you’re not assigned an account manager you can send an email to to request this feature.

2. Integrate listeners to collect post-back

The ILRD event is sent as a JSON blob, to collect the JSON delivered with the ad impression you’ll need to add listeners to capture, parse and relay the information to Firebase:

3. Relay the information as an event to Firebase

Note, we recommend you send all information provided with the impression:

iOS – Sending MoPub ILRD to Firebase

- (void)mopubAd:(id<mpmopubad>)ad didTrackImpressionWithImpressionData:(MPImpressionData * _Nullable)impressionData

// Feed impression data into internal tools or send to third-party analytics
    if (impressionData != nil)
     [FIRAnalytics logEventWithName:kFIREventAdImpression

Android – Sending MoPub ILRD to Firebase

public void onImpression(@NonNull final String adUnitId, @Nullable final ImpressionData impressionData) {

  if (impressionData != null) {
    // Feed impression data into internal tools or send to third-party analytics
    FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(context);

    Bundle params = new Bundle();
    params.putString(FirebaseAnalytics.Param.AD_PLATFORM, “MoPub”);
    params.putString(FirebaseAnalytics.Param.AD_SOURCE, impressionData.network_name);
    params.putString(FirebaseAnalytics.Param.AD_FORMAT, impressionData.adunit_format);
    params.putString(FirebaseAnalytics.Param.AD_UNIT_NAME, impressionData.adunit_name);
    params.putString(FirebaseAnalytics.Param.VALUE, impressionData.publisher_revenue);
    params.putString(FirebaseAnalytics.Param.CURRENCY, impressionData.currency);
    params.putString("precision", impressionData.precision);
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, params);


Unity – Sending MoPub ILRD to Firebase

    private void OnEnable() {
        MoPubManager.OnImpressionTrackedEvent += OnImpressionTrackedEvent;

    private void OnImpressionTrackedEvent(string adUnitId, MoPub.ImpressionData impressionData)
        // Feed impression data into internal tools or send to third-party analytics
        if (impressionData != null) {
          var myImpressionObject = JsonUtility.FromJson<ImpressionObject>(impressionData.JsonRepresentation);
          var impressionParameters = new[] {
              new Firebase.Analytics.Parameter("ad_platform", “MoPub”),
              new Firebase.Analytics.Parameter("ad_source", myImpressionObject.network_name),
              new Firebase.Analytics.Parameter("ad_unit_name", myImpressionObject.adunit_name),
              new Firebase.Analytics.Parameter("ad_format", myImpressionObject.adunit_format),
              new Firebase.Analytics.Parameter("value", myImpressionObject.publisher_revenue),
              new Firebase.Analytics.Parameter("currency", myImpressionObject.currency),
              new Firebase.Analytics.Parameter("precision", myImpressionObject.precision)
          Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);

    public class ImpressionObject
        public string adunit_id;
        public string adunit_name;
        public string adunit_format;
        public string app_version;
        public string id;
        public string currency;
        public string publisher_revenue;
        public string network_name;
        public string network_placement_id;
        public string adgroup_id;
        public string adgroup_name;
        public string adgroup_type;
        public string adgroup_priority;
        public string country;
        public string precision;

Last updated