androidiosflutteradmobbanner-ads

Is using the same AdMob banner ad unit ID for multiple banners in a Flutter app problematic for ad performance?


I am integrating Google AdMob banner ads into my Flutter app. I am currently using the same bannerAdUnitId for all banner ads, but I am concerned whether this approach might impact ad performance or revenue.

Here is the relevant code snippet:

class AdManager {
  static final AdManager _instance = AdManager._internal();
  static AdManager get instance => _instance;

  AdManager._internal();

  BannerAd? normalModeBannerAd;
  BannerAd? categoriesAd;

final bannerAdUnitId =
      Platform.isAndroid ? AppSettings.androidBannerAdId : AppSettings.iosBannerAdId;

Future<void> loadCategoriesAd() async {
    bool result = await TrackingPermissionHandler.instance.checkTrackingPermission();
    if (result) {
      if (kDebugMode) {
        print('Tracking permission granted.');
      }

      categoriesAd = BannerAd(
        adUnitId: bannerAdUnitId,
        size: AdSize.banner,
        request: const AdRequest(nonPersonalizedAds: false),
        listener: BannerAdListener(
          // Called when an ad is successfully received.
          onAdLoaded: (Ad ad) {
            debugPrint('$BannerAd loaded.');
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (Ad ad, LoadAdError error) {
            debugPrint('$BannerAd failedToLoad: $error');
            ad.dispose();
          },
          // Called when an ad opens an overlay that covers the screen.
          onAdOpened: (Ad ad) => debugPrint('$BannerAd onAdOpened.'),
          // Called when an ad removes an overlay that covers the screen.
          onAdClosed: (Ad ad) => debugPrint('$BannerAd onAdClosed.'),
          // Called when an ad is in the process of leaving the application.
        ),
      );

      categoriesAd?.load();
    } else {
      if (kDebugMode) {
        print('Tracking permission is not granted.');
      }
      categoriesAd = BannerAd(
        adUnitId: bannerAdUnitId,
        size: AdSize.banner,
        request: const AdRequest(nonPersonalizedAds: true),
        listener: BannerAdListener(
          // Called when an ad is successfully received.
          onAdLoaded: (Ad ad) {
            debugPrint('$BannerAd loaded.');
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (Ad ad, LoadAdError error) {
            debugPrint('$BannerAd failedToLoad: $error');
            ad.dispose();
          },
          // Called when an ad opens an overlay that covers the screen.
          onAdOpened: (Ad ad) => debugPrint('$BannerAd onAdOpened.'),
          // Called when an ad removes an overlay that covers the screen.
          onAdClosed: (Ad ad) => debugPrint('$BannerAd onAdClosed.'),
          // Called when an ad is in the process of leaving the application.
        ),
      );

      categoriesAd?.load();
    }
  }

  Future<void> loadNormalModeBannerAd() async {
    bool result = await TrackingPermissionHandler.instance.checkTrackingPermission();
    if (result) {
      if (kDebugMode) {
        print('Tracking permission granted.');
      }

      // Dispose existing ad if it exists
      await disposeNormalModeBannerAd();

      normalModeBannerAd = BannerAd(
        adUnitId: bannerAdUnitId,
        size: AdSize.banner,
        request: const AdRequest(nonPersonalizedAds: false),
        listener: BannerAdListener(
          // Called when an ad is successfully received.
          onAdLoaded: (Ad ad) {
            debugPrint('$BannerAd loaded.');
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (Ad ad, LoadAdError error) {
            debugPrint('$BannerAd failedToLoad: $error');
            ad.dispose();
          },
          // Called when an ad opens an overlay that covers the screen.
          onAdOpened: (Ad ad) => debugPrint('$BannerAd onAdOpened.'),
          // Called when an ad removes an overlay that covers the screen.
          onAdClosed: (Ad ad) => debugPrint('$BannerAd onAdClosed.'),
          // Called when an ad is in the process of leaving the application.
        ),
      );

      normalModeBannerAd?.load();
    } else {
      if (kDebugMode) {
        print('Tracking permission is not granted.');
      }

      // Dispose existing ad if it exists
      await disposeNormalModeBannerAd();

      normalModeBannerAd = BannerAd(
        adUnitId: bannerAdUnitId,
        size: AdSize.banner,
        request: const AdRequest(nonPersonalizedAds: true),
        listener: BannerAdListener(
          // Called when an ad is successfully received.
          onAdLoaded: (Ad ad) {
            debugPrint('$BannerAd loaded.');
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (Ad ad, LoadAdError error) {
            debugPrint('$BannerAd failedToLoad: $error');
            ad.dispose();
          },
          // Called when an ad opens an overlay that covers the screen.
          onAdOpened: (Ad ad) => debugPrint('$BannerAd onAdOpened.'),
          // Called when an ad removes an overlay that covers the screen.
          onAdClosed: (Ad ad) => debugPrint('$BannerAd onAdClosed.'),
          // Called when an ad is in the process of leaving the application.
        ),
      );

      normalModeBannerAd?.load();
    }
  }
}

Should I use different ad unit IDs for different banner ads within the same app, and how might this impact ad performance and revenue?


Solution

  • It's not a problem at all to use the same banner ID on different screens. If you wish, you can create another banner and load different banner IDs on different screens. Having multiple banners gives you better options for analytics. However, if you use the same banner multiple times on the same screen, you may get an error.