Integration of Google Publisher Tag - android

Integrating Google Publisher Tags (GPT) from Google Ad Manager (GAM) into an Android application involves setting up GAM, integrating the GPT library, defining ad units, and testing ad delivery. Here's a step-by-step guide to help you integrate GPT and test ad delivery in your Android application:

Step 1: Set Up Google Ad Manager (GAM)

  1. Create a Google Ad Manager account if you don't have one:
  2. Set up an application in GAM and create ad units as described in previous sections.

Step 2: Integrate Google Publisher Tags (GPT) Library

  1. Add the GPT library dependency to your app's build.gradle file:
    implementation '' // Replace with the latest version
  2. Sync your project to download the library.

Step 3: Configure GPT in Your Android App

  1. Import the necessary classes in your activity where you want to display ads:
  2. Initialize GPT with your Ad Manager ad unit ID and ad size:
    String adUnitID = "/YOUR/AD_UNIT_ID";
    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER); // You can choose other ad sizes as well
  3. Load and display the ad:
    AdRequest adRequest = new AdRequest.Builder().build();

Step 4: Test Ad Delivery

  1. Use Google's test ad unit IDs for testing. Replace "/YOUR/AD_UNIT_ID" with the appropriate test ad unit ID:
    • Test banner ad: /6499/example/banner
    • Test interstitial ad: /6499/example/interstitial
  2. Make sure you are not using real ad unit IDs during testing to prevent serving live ads.
  3. Run your Android app on an emulator or a real device to test the ad delivery. Ensure you have an active internet connection.

Additional Steps

  • Implement GPT ad event listeners to handle ad lifecycle events, such as ad loaded, ad clicked, etc.
  • Test different ad formats, sizes, and targeting options using the GPT library.

Please refer to the Google Publisher Tags (GPT) documentation and the Google Mobile Ads Android SDK documentation for more detailed information, guides, and code examples.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.