To discuss and provide feedback on our products, join the official AdMob Discord channel in the Google Advertising and Measurement Community server.

Impression-level ad revenue

  • Implement a paid event handler to capture impression-level ad revenue data for calculating user lifetime value and forwarding to analytics platforms.

  • Enable the impression-level ad revenue feature in AdMob, integrate the Google Mobile Ads SDK (9.10.0 or higher), and implement an ad format to start receiving impression data.

  • Set the paid event handler for your ad objects before displaying them and promptly forward the received data to your analytics server to ensure comprehensive data collection.

  • Utilize GADAdValue to access the monetary value, currency code, and precision type of each ad impression.

  • Understand the different GADAdValuePrecision values and how they reflect the accuracy and source of the ad value data.

Select platform: Android iOS Unity

When an impression occurs, Google Mobile Ads SDK calls the paid event handler with its associated revenue data. By implementing this handler, you can use the data to calculate a user's lifetime value, or forward the data downstream to other relevant systems.

This guide is intended to help you implement LTV data capture in your iOS app.

Prerequisites

Implement a paid event handler

Each ad format has a paidEventHandler property of type GADPaidEventHandler. During the lifecycle of an ad event, Google Mobile Ads SDK monitors impression events and invokes the handler with an earned value.

Swift

classViewController:UIViewController,FullScreenContentDelegate{
varrewardedAd:RewardedAd?
funcrequestRewardedAd(){
RewardedAd.load(
with:"AD_UNIT_ID",request:Request()
){(ad,error)in
ifleterror=error{
print("Rewarded ad failed to load with error: \(error.localizedDescription)")
return
}
ifletad=ad{
self.rewardedAd=ad
self.rewardedAd?.paidEventHandler={adValuein
// TODO: Send the impression-level ad revenue information to your preferred analytics
// server directly within this callback.
// Extract the impression-level ad revenue data.
letvalue=adValue.value
letprecision=adValue.precision
letcurrencyCode=adValue.currencyCode
// Get the ad unit ID.
letadUnitId=ad.adUnitID
letresponseInfo=ad.responseInfo
letloadedAdNetworkResponseInfo=responseInfo?.loadedAdNetworkResponseInfo
letadSourceId=loadedAdNetworkResponseInfo?.adSourceID
letadSourceInstanceId=loadedAdNetworkResponseInfo?.adSourceInstanceID
letadSourceInstanceName=loadedAdNetworkResponseInfo?.adSourceInstanceName
letadSourceName=loadedAdNetworkResponseInfo?.adSourceName
letmediationGroupName=responseInfo?.extras["mediation_group_name"]
letmediationABTestName=responseInfo?.extras["mediation_ab_test_name"]
letmediationABTestVariant=responseInfo?.extras["mediation_ab_test_variant"]
}
}
}
}
}

Objective-C

@importGoogleMobileAds;
@importUIKit;
@interface ViewController()
@property(nonatomic,strong)GADRewardedAd*rewardedAd;
@end
@implementation ViewController
- (void)requestRewardedAd{
__weakViewController*weakSelf=self;
GADRequest*request=[GADRequestrequest];
[GADRewardedAd
loadWithAdUnitID:@"AD_UNIT_ID"
request:request
completionHandler:^(GADRewardedAd*ad,NSError*error){
if(error){
NSLog(@"Rewarded ad failed to load with error: %@",[errorlocalizedDescription]);
return;
}
self.rewardedAd=ad;
self.rewardedAd.paidEventHandler=^void(GADAdValue*_Nonnullvalue){
ViewController*strongSelf=weakSelf;
// TODO: Send the impression-level ad revenue information to your preferred analytics
// server directly within this callback.
// Extract the impression-level ad revenue data.
NSDecimalNumber*value;=value.value;
NSString*currencyCode=value.currencyCode;
GADAdValuePrecisionprecision=value.precision;
// Get the ad unit ID.
NSString*adUnitId=strongSelf.rewardedAd.adUnitID;
GADAdNetworkResponseInfo*loadedAdNetworkResponseInfo=
strongSelf.rewardedAd.responseInfo.loadedAdNetworkResponseInfo;
NSString*adSourceName=loadedAdNetworkResponseInfo.adSourceName;
NSString*adSourceID=loadedAdNetworkResponseInfo.adSourceID;
NSString*adSourceInstanceName=loadedAdNetworkResponseInfo.adSourceInstanceName;
NSString*adSourceInstanceID=loadedAdNetworkResponseInfo.adSourceInstanceID;
NSDictionary<NSString*,id>*extras=strongSelf.rewardedAd.responseInfo.extrasDictionary;
NSString*mediationGroupName=extras["mediation_group_name"];
NSString*mediationABTestName=extras["mediation_ab_test_name"];
NSString*mediationABTestVariant=extras["mediation_ab_test_variant"];
};
]};
}

Identify a custom event ad source name

For custom event ad sources, adSourceName property gives you the ad source name Custom event. If you use multiple custom events, the ad source name isn't granular enough to distinguish between multiple custom events. To locate a specific custom event, do the following steps:

  1. Get the adNetworkClassName property.
  2. Set a unique ad source name.

The following example sets a unique ad source name for a custom event:

Swift

funcuniqueAdSourceName(forloadedAdNetworkResponseInfo:AdNetworkResponseInfo)->String{
varadSourceName:String=loadedAdNetworkResponseInfo.adSourceName??""
ifadSourceName=="Custom Event"{
ifloadedAdNetworkResponseInfo.adNetworkClassName
=="MediationExample.SampleCustomEventSwift"
{
adSourceName="Sample Ad Network (Custom Event)"
}
}
returnadSourceName
}

Objective-C

- (NSString*)uniqueAdSourceNameForAdNetworkResponseInfo:
(GADAdNetworkResponseInfo*)loadedAdNetworkResponseInfo{
NSString*adSourceName=loadedAdNetworkResponseInfo.adSourceName;
if([adSourceNameisEqualToString:@"Custom Event"]){
if([loadedAdNetworkResponseInfo.adNetworkClassNameisEqualToString:@"SampleCustomEvent"]){
adSourceName=@"Sample Ad Network (Custom Event)";
}
}
returnadSourceName;
}

For more information on the winning ad source, see Retrieve information about the ad response.

Integrate with App Attribution Partners (AAP)

For complete details on forwarding ads revenue data to analytics platforms, refer to the partner's guide:

Partner SDK
Adjust
AppsFlyer
Singular
Tenjin

Implementation best practices

  • Set the handler immediately once you create or get access to the ad object, and definitely before showing the ad. This makes sure that you don't miss any paid event callbacks.
  • Send the paid event information to your preferred analytics server immediately at the time the paidEventHandler method is called. This makes sure that you don't accidentally drop any callbacks and avoids data discrepancies.

GADAdValue

GADAdValue is a class that represents the monetary value earned for an ad, including the value's currency code and its precision type encoded as following.

GADAdValuePrecision Description
GADAdValuePrecisionUnknown An ad value that's unknown. This gets returned when LTV pingback is enabled but there isn't enough data available.
GADAdValuePrecisionEstimated An ad value estimated from aggregated data.
GADAdValuePrecisionPublisherProvided A publisher provided ad value, such as manual CPMs in a mediation group.
GADAdValuePrecisionPrecise The precise value paid for this ad.

Test impressions from bidding ad sources

After an impression-level ad revenue event occurs for a bidding ad source through a test request, you receive only the following values:

  • GADAdValuePrecisionUnknown: indicates the precision type.
  • 0: indicates the ad value.

Previously, you might have seen the precision type as a value other than GADAdValuePrecisionUnknown and an ad value more than 0.

For details on sending a test ad request, see Enable test devices.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月14日 UTC.