Impression-Level Revenue Data

Before you begin

  • Make sure you have integrated OpenMediation SDK v2.1.0 or higher.

ILRD Data

The ILRD Data is returned as part of the ImpressionData object. Here’s a list of the relevant data fields, including description and type.

Field Name Datatype Description
impression_id String A unique ID for each impression
instance_id String Identifier per network, this includes the ad network’s
instanceID/placement/zone/etc.
instance_name String The ad network instance name as defined on the platform
instance_priority Integer The instance priority in mediation rule
ad_network_name String The ad network name that served the ad
ad_network_unit_id String The ad unit displayed (Rewarded Video/Interstitial/Banner/Native/Splash/Cross Promote)
mediation_rule_id String The id of mediation rule
mediation_rule_name String The name of mediation rule
mediation_rule_type String The type of mediation rule:
Manual or Auto
mediation_rule_priority Integer The priority of mediation rule
placement_id String Ad Placement ID
placement_name String Ad Placement Name
placement_ad_type String Ad Placement Type:
Banner/Native/Rewarded Video/Interstitial/Splash/CrossPromote
scene_name String Scene Name, null for Banner/Native/Splash
currency String Is always "USD"
revenue Double The revenue generated for the impression (USD). The revenue value is either estimated or exact, according to the precision (see precision field description)
precision String The source value of the revenue field:
undisclosed - non-public data, for example, FAN requires not to store revenue data
exact - exact value, generally the benefit brought by in-app bidding type instance
estimated - estimated value, estimated from the historical income data of ordinary instance
ab_group String Indication if A/B test was activated via platform
lifetime_value Double The accumulated value of the user ad revenue

 

Implement the Impression Callback Interface

OpenMediation SDK v2.1.0 and higher has the public interface ImpressionDataListener. This listener is notified when an impression is fired for any format of ad shown.

Note that parameter data in onImpression() is null unless you have enabled the ILRD feature with your OpenMediation account representative.

1. Implement the interface ImpressionDataListener and subscribe to events from OmAds.addImpressionDataListener(listener) to receive detailed impression data. We recommend that you subscribe to events when your first activity is created.

import com.openmediation.sdk.OmAds;
import com.openmediation.sdk.ImpressionData;
import com.openmediation.sdk.ImpressionDataListener;
import com.openmediation.sdk.utils.error.Error;

ImpressionDataListener listener = new ImpressionDataListener() {
    @Override
    public void onImpression(Error error, ImpressionData impressionData) {
        if (impressionData != null) {
            // To make it easy to use, you can refer to each field separately, 
            // or get all information using the allData method:
            impressionData.getAllData();
        } else {
            // impression data not available
        }
    }
});

2. Call OmAds.addImpressionDataListener(listener) to start listening for impression-level revenue data events.

3. Call OmAds.removeImpressionDataListener(listener) to unsubscribe from impression-level revenue data events.

OmAds.addImpressionDataListener(listener);
OmAds.removeImpressionDataListener(listener);

Make sure to not leak any ImpressionDataListeners. If your listener is tied to the activity lifecycle, make sure to remove the listener when the activity is destroyed.

 

Example

import com.openmediation.sdk.OmAds;
import com.openmediation.sdk.ImpressionData;
import com.openmediation.sdk.ImpressionDataListener;

    private ImpressionDataListener mImpressionListener;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mImpressionListener = new ImpressionDataListener() {
            @Override
            public void onImpression(Error error, ImpressionData impressionData) {
            }
        };
        // subscribe to start listening for impression data
        OmAds.addImpressionDataListener(mImpressionListener);
    }

    @Override
    protected void onDestroy() {
        // Remove the listener to unsubscribe
        OmAds.removeImpressionDataListener(mImpressionListener);
        super.onDestroy();
    }

 

Send Data to Other Tools or Vendors

Once you receive impression data, you can feed it to your internal Business Intelligence (BI) tools, or send it to third-party attribution and analytics providers for further analysis.

 

Example

The example below shows how to send ILRD to Google Analytics for Firebase. You can use it as is, or make any required changes, in order to integrate with 3rd party reporting tools or your own proprietary optimization tools and databases.

@Override
public void onImpression(Error error, 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, "OpenMediation");
        params.putString(FirebaseAnalytics.Param.AD_SOURCE, impressionData.getAdNetworkName());
        params.putString(FirebaseAnalytics.Param.AD_FORMAT, impressionData.getPlacementAdType());
        params.putString(FirebaseAnalytics.Param.AD_UNIT_NAME, impressionData.getPlacementName());
        params.putDouble(FirebaseAnalytics.Param.VALUE, impressionData.getRevenue());
        params.putString(FirebaseAnalytics.Param.CURRENCY, impressionData.getCurrency());
        params.putString("precision", impressionData.getPrecision());
        firebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, params);
    }
}

 

 

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.