各広告フォーマットには OnAdPaid イベントが含まれています。Google Mobile Ads SDK は広告イベントのライフサイクル全体でインプレッション イベントを監視しており、インプレッションが発生すると、得られた収益の値を表す AdValue とともにハンドラを呼び出します。
次の例では、リワード広告の有料イベントを処理しています。
privatevoidLoadRewardedAd(){// Send the request to load the ad.AdRequestadRequest=newAdRequest();RewardedAd.Load("AD_UNIT_ID",adRequest,(RewardedAdrewardedAd,LoadAdErrorerror)=>
{// If the operation failed with a reason.if(error!=null){Debug.LogError("Rewarded ad failed to load an ad with error : "+error);return;}rewardedAd.OnAdPaid+=this.HandleAdPaidEvent;});}publicvoidHandleAdPaidEvent(AdValueadValue){// TODO: Send the impression-level ad revenue information to your// preferred analytics server directly within this callback.longvalueMicros=adValue.Value;stringcurrencyCode=adValue.CurrencyCode;PrecisionTypeprecision=adValue.Precision;ResponseInforesponseInfo=rewardedAd.GetResponseInfo();stringresponseId=responseInfo.GetResponseId();AdapterResponseInfoloadedAdapterResponseInfo=responseInfo.GetLoadedAdapterResponseInfo();stringadSourceId=loadedAdapterResponseInfo.AdSourceId;stringadSourceInstanceId=loadedAdapterResponseInfo.AdSourceInstanceId;stringadSourceInstanceName=loadedAdapterResponseInfo.AdSourceInstanceName;stringadSourceName=loadedAdapterResponseInfo.AdSourceName;stringadapterClassName=loadedAdapterResponseInfo.AdapterClassName;longlatencyMillis=loadedAdapterResponseInfo.LatencyMillis;Dictionary<string,string>credentials=loadedAdapterResponseInfo.AdUnitMapping;Dictionary<string,string>extras=responseInfo.GetResponseExtras();stringmediationGroupName=extras["mediation_group_name"];stringmediationABTestName=extras["mediation_ab_test_name"];stringmediationABTestVariant=extras["mediation_ab_test_variant"];}
[null,null,["最終更新日 2025-08-28 UTC。"],[[["\u003cp\u003eImplement impression-level ad revenue data capture in your Unity project to calculate user lifetime value or forward data to other systems.\u003c/p\u003e\n"],["\u003cp\u003eBefore implementation, ensure the feature is enabled in AdMob, use Unity plugin 5.0.0 or higher, complete Get Started, and implement at least one ad format (Banner, Interstitial, Rewarded, Rewarded Interstitial, or Native).\u003c/p\u003e\n"],["\u003cp\u003eIntegrate the \u003ccode\u003eOnAdPaid\u003c/code\u003e event handler for each ad format to receive ad revenue data via the \u003ccode\u003eAdValue\u003c/code\u003e object, containing value, currency, precision, and ad source information.\u003c/p\u003e\n"],["\u003cp\u003eForward the received impression-level ad revenue data to your analytics server directly within the \u003ccode\u003eOnPaidEvent\u003c/code\u003e handler for real-time processing and to prevent data loss.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAdValue\u003c/code\u003e object provides the monetary value earned for an ad in micros, along with its currency code and precision type (Unknown, Estimated, PublisherProvided, or Precise).\u003c/p\u003e\n"]]],["The Google Mobile Ads SDK provides impression-level ad revenue data upon each ad impression. To capture this data in a Unity project, ensure the feature is enabled in AdMob, use Unity plugin 5.0.0+, and implement at least one ad format. Each format has an `OnAdPaid` event triggered by the SDK, passing an `AdValue` object. This object, including currency code and precision, is handled in the `HandleAdPaidEvent` function where you send the data to your analytics server. Integration with partners like Adjust and AppsFlyer is possible, and best practice is to set the `OnPaidEvent` immediately.\n"],null,["Select platform: [Android](/admob/android/impression-level-ad-revenue \"View this page for the Android platform docs.\") [iOS](/admob/ios/impression-level-ad-revenue \"View this page for the iOS platform docs.\") [Unity](/admob/unity/impression-level-ad-revenue \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\nWhen an impression occurs, Google Mobile Ads SDK provides ad revenue data\nassociated with that impression. You can use the data to calculate a user's\nlifetime value, or forward the data downstream to other relevant systems.\n\nThis guide is intended to help you implement the impression-level ad revenue\ndata capture in your Unity project.\n\nPrerequisites\n\n- Make sure you have [turned on the impression-level ad revenue\n feature](//support.google.com/admob/answer/11322405) in the AdMob UI.\n- Unity plugin 5.0.0 or higher.\n- Complete [Get Started](/admob/unity/quick-start). Your Unity app should already have the Google Mobile Ads Unity plugin imported.\n- Before you can receive any impression-level ad revenue data, you need to\n implement at least one ad format:\n\n - [Banner](/admob/unity/banner)\n - [Interstitial](/admob/unity/interstitial)\n - [Rewarded](/admob/unity/rewarded)\n - [Rewarded interstitial](/admob/unity/rewarded-interstitial)\n - [Native](/admob/unity/native-advanced-unified)\n\nImplementing a paid event handler\n\nEach ad format has an `OnAdPaid` event. During the lifecycle of an ad event,\nGoogle Mobile Ads SDK monitors impression events and invokes the handler\nwith a `AdValue` representing the earned value.\n\nThe following example handles paid events for a rewarded ad: \n\n private void LoadRewardedAd()\n {\n // Send the request to load the ad.\n AdRequest adRequest = new AdRequest();\n RewardedAd.Load(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\", adRequest, (RewardedAd rewardedAd, LoadAdError error) =\u003e\n {\n // If the operation failed with a reason.\n if (error != null)\n {\n Debug.LogError(\"Rewarded ad failed to load an ad with error : \" + error);\n return;\n }\n\n rewardedAd.OnAdPaid += this.HandleAdPaidEvent;\n });\n }\n\n public void HandleAdPaidEvent(AdValue adValue)\n {\n // TODO: Send the impression-level ad revenue information to your\n // preferred analytics server directly within this callback.\n long valueMicros = adValue.Value;\n string currencyCode = adValue.CurrencyCode;\n PrecisionType precision = adValue.Precision;\n ResponseInfo responseInfo = rewardedAd.GetResponseInfo();\n string responseId = responseInfo.GetResponseId();\n AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.GetLoadedAdapterResponseInfo();\n string adSourceId = loadedAdapterResponseInfo.AdSourceId;\n string adSourceInstanceId = loadedAdapterResponseInfo.AdSourceInstanceId;\n string adSourceInstanceName = loadedAdapterResponseInfo.AdSourceInstanceName;\n string adSourceName = loadedAdapterResponseInfo.AdSourceName;\n string adapterClassName = loadedAdapterResponseInfo.AdapterClassName;\n long latencyMillis = loadedAdapterResponseInfo.LatencyMillis;\n Dictionary\\\u003cstring, string\\\u003e credentials = loadedAdapterResponseInfo.AdUnitMapping;\n Dictionary\\\u003cstring, string\\\u003e extras = responseInfo.GetResponseExtras();\n string mediationGroupName = extras\\[\"mediation_group_name\"\\];\n string mediationABTestName = extras\\[\"mediation_ab_test_name\"\\];\n string mediationABTestVariant = extras\\[\"mediation_ab_test_variant\"\\];\n }\n\nIdentify a custom event ad source name\n\nFor custom event ad sources, `AdSourceName` property gives you the ad source\nname `Custom Event`. If you use multiple custom events, the ad source name isn't\ngranular enough to distinguish between multiple custom events. To locate a\nspecific custom event, do the following steps:\n\n1. Get the `AdapterClassName` property.\n2. Set a unique ad source name.\n\nThe following example sets a unique ad source name for a custom event: \n\n private string GetAdSourceName(AdapterResponseInfo loadedAdapterResponseInfo)\n {\n if (loadedAdapterResponseInfo == null)\n {\n return string.Empty;\n }\n\n string adSourceName = loadedAdapterResponseInfo.AdSourceName;\n\n if (adSourceName == \"Custom Event\")\n {\n\n #if UNITY_ANDROID\n if (loadedAdapterResponseInfo.AdapterClassName ==\n \"com.google.ads.mediation.sample.customevent.SampleCustomEvent\")\n {\n adSourceName = \"Sample Ad Network (Custom Event)\";\n }\n #elif UNITY_IPHONE\n if (loadedAdapterResponseInfo.AdapterClassName == \"SampleCustomEvent\")\n {\n adSourceName = \"Sample Ad Network (Custom Event)\";\n }\n #endif\n\n }\n return adSourceName;\n } \n https://github.com/googleads/googleads-mobile-unity/blob/0f0ef22a4a4b1894951539831f9e3947ff634a75/samples/HelloWorld/Snippets/ResponseInfoSnippets.cs#L12-L39\n\nFor more information on the winning ad source, see [Retrieve information about\nthe ad response](/admob/unity/response-info).\n\nIntegrate with App Attribution Partners (AAP)\n\nFor complete details on forwarding ad revenue data to analytics platforms,\nrefer to the partner's guide:\n\n| Partner SDK |\n|----------------------------------------------------------------------------------------------------------------------------------------|\n| [Adjust](//dev.adjust.com/en/sdk/unity/integrations/admob) |\n| [AppsFlyer](//support.appsflyer.com/hc/en-us/articles/4416353506833) |\n| [Singular](//support.singular.net/hc/en-us/articles/360037635452-Unity-SDK-Integration-Guide#42_Adding_Ad_Revenue_Attribution_Support) |\n| [Tenjin](//docs.tenjin.com/en/send-events/unity.html#ilrd) |\n\nImplementation best practices\n\n- Set the `OnPaidEvent` event 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 callbacks.\n- Send the impression-level ad revenue information to your preferred analytics server immediately in your `OnPaidEvent` handler. This makes sure that you don't accidentally drop any callbacks and avoids data discrepancies.\n\nAdValue\n\n`AdValue` is a class that represents the monetary value earned for an ad,\nincluding the value's currency code and its precision type encoded as follows.\n| **Key Point:** The value of `AdValue` is a micro value that represents each ad's worth. For example, a value of 5,000 indicates that this ad is estimated to be worth $0.005.\n\n| `AdValue.PrecisionType` | Description |\n|-------------------------|--------------------------------------------------------------------------------------------------------------------|\n| `Unknown` | An ad value that's unknown. This gets returned when LTV pingback is enabled but there isn't enough data available. |\n| `Estimated` | An ad value estimated from aggregated data. |\n| `PublisherProvided` | A publisher provided ad value, such as manual CPMs in a mediation group. |\n| `Precise` | The precise value of this ad. |\n\nIn case of mediation, AdMob tries to provide an `Estimated`value for ad sources\nthat are [optimized](//support.google.com/admob/answer/7374110). For\nnon-optimized ad sources, or in cases where there aren't enough aggregated data\nto report a meaningful estimation, the `PublisherProvided` value is returned.\n\nTest impressions from bidding ad sources\n\nAfter an impression-level ad revenue event occurs for\na bidding ad source through a test request, you receive only the following\nvalues:\n\n- `Unknown`: indicates the precision type.\n\n\u003c!-- --\u003e\n\n- `0`: indicates the ad value.\n\nPreviously, you might have seen the precision type as a value other than\n`Unknown`\nand an ad value more than `0`.\n\nFor details on sending a test ad request, see\n[Enable test devices](/admob/unity/test-ads#enable-test-devices)."]]