Skip to content

Impression Level Data

Str4tos edited this page Mar 11, 2024 · 16 revisions

⚡ 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

AdMetaData is an class 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:

void OnEnable()
{
    if (manager == null) return;
    manager.GetAdView(AdSize.Banner).OnImpression += HandleAdViewImpression;
    manager.OnInterstitialAdImpression += HandleInterstitialAdImpression;
    manager.OnRewardedAdImpression += HandleRewardedAdImpression;
    manager.OnAppReturnAdImpression += HandleAppReturnAdImpression;
}
void OnDisable()
{
    if (manager == null) return;
    manager.GetAdView(AdSize.Banner).OnImpression -= HandleAdViewImpression;
    manager.OnInterstitialAdImpression -= HandleInterstitialAdImpression;
    manager.OnRewardedAdImpression -= HandleRewardedAdImpression;
    manager.OnAppReturnAdImpression -= HandleAppReturnAdImpression;
}

private void HandleAdViewImpression(IAdView view, AdMetaData impression)
{
    // Get ad details of Banner Ad using impression parameter
}
private void HandleInterstitialAdImpression(AdMetaData impression)
{
    // Get ad details of Interstitial Ad using impression parameter
}
private void HandleRewardedAdImpression(AdMetaData impression)
{
    // Get ad details of Rewarded Ad using impression parameter
}
private void HandleAppReturnAdImpression(AdMetaData impression)
{
    // Get ad details of AppReturn Ad using impression parameter
}

Ad revenue

The revenue generated for the impression (USD). The revenue value is either estimated or exact, according to the priceAccuracy property.

double revenue = impression.revenue;

You can also check the precision estimate for the revenue value, as shown in the following example:

PriceAccuracy precision = impression.priceAccuracy;
if (precision == PriceAccuracy.Floor)
{
    // The estimated revenue, can also be a minimum price (floor) for ad impression.
}
else if (precision == PriceAccuracy.Bid)
{
    // The revenue provided as part of the real-time auction.
}
else
{
    // The revenue is '0', when the demand source does not agree to disclose the payout of impression. 
}

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.adType;
string creativeId = impression.creativeIdentifier;
string networkName = impression.network;
string networkSDKVersion = impression.versionInfo;
string casUnitId = impression.identifier;

Warning

impression.creativeIdentifier may return null.

A list of all supported networks can be found in AdNetwork class. For example:

if (networkName == AdNetwork.GoogleAds)
{
    // Impression from Google Ads 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.impressionDepth;
double totalRevenue = impression.lifetimeRevenue;

Note

Progress is saved between sessions until the user clears your app's data.

Automatic collect ad revenue

The CleverAdsSolution SDK have feature to automatically logs the ad_impression event whenever your users see an ad impression.

Contact support for details of enabling automatic logs the events to Google Analytics from your CAS application.

Custom collect ad revenue

The following code shows an implementation example for log AD_IMPRESSION event to Google Analytics.

void CollectImpression(AdMetaData impression)
{
    if (impression.priceAccuracy == PriceAccuracy.Undisclosed) 
    { 
        return;
    }
    
    Firebase.Analytics.Parameter[] AdParameters = {
        new Firebase.Analytics.Parameter("ad_platform", "CAS"),
        new Firebase.Analytics.Parameter("ad_source", impression.network),
        new Firebase.Analytics.Parameter("ad_unit_name", impression.identifier),
        new Firebase.Analytics.Parameter("ad_format", impression.adType.ToString()),
        new Firebase.Analytics.Parameter("currency", "USD"), // All CAS revenue is sent in USD 
        new Firebase.Analytics.Parameter("value", impression.revenue)
    };
    Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", AdParameters);
}
Clone this wiki locally