Impression Level Data - cleveradssolutions/CAS-Android GitHub Wiki
:zap: Before you start
Make sure you have correctly Initialize CAS.
CleverAdsSolutions enables you to access detailed information for each impression through the impressions callback APIs. The information includes, for example, which demand source served the ad, the expected or exact revenue associated with it. In addition, it contains granular details to allow you to analyze and, ultimately, optimize user acquisition strategies.
Ad Impression
AdImpression
(AdStatusHandler
for Java) is an interface for getting detailed information about the current ad impression, such as revenue and ad creative details.
Each ad format has a callback to receive an AdImpression
about the current impression.
The code below demonstrates how to handle impression events for Interstitial ad and Banner ad:
manager.showInterstitial(this, new AdPaidCallback() {
@Override
public void onAdRevenuePaid(@NonNull AdStatusHandler impression) {
// Get ad details using impression parameter
}
});
manager.showRewarded(this, new AdPaidCallback() {
@Override
public void onAdRevenuePaid(@NonNull AdStatusHandler impression) {
// Get ad details using impression parameter
}
});
bannerView.setAdListener(new AdViewListener() {
@Override
public void onAdViewPresented(@NonNull CASBannerView view,
@NonNull AdStatusHandler impression) {
// Get ad details using impression parameter
}
});
Ad revenue
Use the cpm
property to get a revenue estimate for the current impression.
The value of the cpm
property is Cost Per Mille estimated impressions. To earn per impression revenue, follow these steps:
Double cpm = impression.getCpm();
You can also check the precision estimate for the cpm
value, as shown in the following example:
int precision = impression.getPriceAccuracy();
if (precision == PriceAccuracy.FLOOR) {
// The value is minimum eCPM, obtained from the ad network waterfall configuration.
} else if (precision == PriceAccuracy.BID) {
// The value is exact and committed per 1000 impressions
} else{
// The value is not disclosed by the demand source. getCpm() will return 0.
}
Ad creative
You can also retrieve information about the current ad (such as its mediated network and creative ID), and you will be able to report creative issues for that ad to our Ad review team.
AdType placementType = impression.getAdType();
@Nullable String creativeId = impression.getCreativeIdentifier();
String networkName = impression.getNetwork();
String networkSDKVersion = impression.getVersionInfo();
String casUnitId = impression.getIdentifier();
[!WARNING]
impression.getCreativeIdentifier()
may return null.
A list of all supported networks can be found in AdNetwork
class. For example:
if (networkName == AdNetwork.VUNGLE) {
// Impression from Vungle network.
}
User ad summary
CAS count the number of ad impressions and the total revenue of all formats at the time of a new impression.
int totalImpressions = impression.getImpressionDepth();
Double totalRevenue = impression.getLifetimeRevenue();
[!NOTE]
Progress is saved between sessions until the user clears your app's data.
Automatic collect ad revenue
The CAS SDK have features to automatically collect ad revenue to Google Analytics and Tenjin Analytics. Contact your account manager for details of enabling automatic events.
Google Analytics
If you haven't already, make sure to complete the following tasks:
- Set up your project and app as described in Get Started with Analytics.
- Make sure that you've linked your Firebase project to a Google Analytics account.
- Ensure that you've included in your app the CAS SDK 3.5.0+.
To measure ad revenue, CAS SDK log ad_impression
events whenever your user sees an advertisement in your app. These events contain details such as the ad platform, source, currency, and value. Optionally, the alternative event name can be CAS_Impression
.
Tenjin
If you haven't already, make sure to complete the following tasks:
- Set up your project and app as described in Get Started with Analytics.
- Make sure that you've initialize tenjin session.
- Ensure that you've included in your app the CAS SDK 3.7.2+.
Custom collect ad revenue
The following code shows an implementation example for log AD_IMPRESSION
event to Google Analytics.
if (impression.getPriceAccuracy() == PriceAccuracy.UNDISCLOSED) {
return;
}
Double revenue = impression.getCpm() / 1000.0;
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.AD_PLATFORM, "CAS");
params.putString(FirebaseAnalytics.Param.AD_SOURCE, impression.getNetwork());
params.putString(FirebaseAnalytics.Param.AD_FORMAT,
impression.getAdType().name());
params.putString(FirebaseAnalytics.Param.AD_UNIT_NAME,
impression.getIdentifier());
params.putDouble(FirebaseAnalytics.Param.VALUE, revenue);
// All CAS revenue is sent in USD
params.putString(FirebaseAnalytics.Param.CURRENCY, "USD");
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, params);