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

Logging Ad Response Info ID to Crashlytics

  • Firebase Crashlytics helps you manage app stability by grouping crashes and highlighting their causes.

  • This guide shows you how to integrate Crashlytics into your Unity project and log ad response IDs.

  • Logging ad response IDs with crash reports allows you to identify and block problematic ads using AdMob's Ad Review Center.

  • Integration involves adding Firebase to your Unity project, initializing the SDKs, requesting a banner ad, and logging the ad response ID to Crashlytics on ad load.

Select platform: Android iOS Unity

Firebase Crashlytics is a lightweight, realtime crash reporter that makes it easy for you to manage stability issues in your app. Crashlytics saves you troubleshooting time by intelligently grouping crashes and highlighting the circumstances that lead up to them.

This guide describes how to integrate Crashlytics into your Unity project so that you can log ad response IDs. Later, when you troubleshoot crashes in your app, you can look up the ad response IDs and use the Ad Review Center in AdMob to find and block the ads.

Step 1: Add Firebase to your Unity app

Follow the Firebase Unity integration guide to integrate Firebase Crashlytics into Unity.

Step 2: Log the ad response ID

  1. Create a MonoBehaviour script and initialize both AdMob and Firebase SDKs. Use the boolean isCrashlyticsInitialized to monitor when Crashlytics initializes.

    usingGoogleMobileAds.Api;
    usingFabric.Crashlytics;
    ...
    publicclassGameObjectScript:MonoBehaviour
    {
    boolisCrashlyticsInitialized=false;
    publicvoidStart()
    {
    ....
    // Initialize Google Mobile Ads SDK.
    MobileAds.Initialize((InitializationStatusinitStatus)=>{});
    ....
    // Initialize Firebase
    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task=>{
    Firebase.DependencyStatusdependencyStatus=task.Result;
    if(dependencyStatus==Firebase.DependencyStatus.Available)
    {
    Firebase.FirebaseAppapp=Firebase.FirebaseApp.DefaultInstance;
    isCrashlyticsInitialized=true;
    }
    else
    {
    UnityEngine.Debug.LogError(System.String.Format(
    "Could not resolve all Firebase dependencies: {0}",dependencyStatus));
    // Firebase Unity SDK is not safe to use here.
    }
    });
    }
    }
    
  2. Request a banner ad.

    usingGoogleMobileAds.Api;
    usingFabric.Crashlytics;
    ...
    publicclassGameObjectScript:MonoBehaviour
    {
    publicvoidStart()
    {
    ...
    // Initialize Google Mobile Ads SDK.
    MobileAds.Initialize((InitializationStatusinitStatus)=>{});
    // Initialize Firebase.
    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task=>{
    Firebase.DependencyStatusdependencyStatus=task.Result;
    if(dependencyStatus==Firebase.DependencyStatus.Available)
    {
    // Create and hold a reference to your FirebaseApp,
    // where app is a Firebase.FirebaseApp property of your
    // application class.
    // Crashlytics will use the DefaultInstance, as well;
    // this ensures that Crashlytics is initialized.
    Firebase.FirebaseAppapp=Firebase.FirebaseApp.DefaultInstance;
    isCrashlyticsInitialized=true;
    }
    else
    {
    UnityEngine.Debug.LogError(System.String.Format(
    "Could not resolve all Firebase dependencies: {0}",dependencyStatus));
    // Firebase Unity SDK is not safe to use here.
    }
    });
    // Request Banner View.
    this.RequestBanner();
    ...
    }
    publicvoidRequestBanner()
    {
    #if UNITY_ANDROID
    stringadUnitId="ca-app-pub-3940256099942544/6300978111";
    #elif UNITY_IPHONE
    stringadUnitId="ca-app-pub-1220882738324941/1255739139";
    #else
    stringadUnitId="unexpected_platform";
    #endif
    // Create a 320x50 banner at the top of the screen.
    this.bannerView=newBannerView(adUnitId,AdSize.Banner,AdPosition.Bottom);
    // Called when an ad request has successfully loaded.
    this.bannerView.OnAdLoaded+=this.HandleOnAdLoaded;
    AdRequestrequest=newAdRequest();
    this.bannerView.LoadAd(request);
    }
    }
    
  3. Get the ResponseInfo object OnAdLoaded and log the response ID to Crashlytics.

publicvoidHandleOnAdLoaded()
{
ResponseInforesponseInfo=this.bannerView.GetResponseInfo();
if(responseInfo!=null)
{
StringadResponseId=responseInfo.GetResponseId();
// Log to Crashlytics.
if(isCrashlyticsInitialized)
{
Crashlytics.SetCustomKey("banner_ad_response_id",adResponseId);
}
}
}

That's it! You can now see the most recent banner_ad_response_id in the key section of crash sessions on your Crashlytics dashboard. Note that some keys may take up to four hours to become visible on your dashboard.

response id

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月15日 UTC.