How to pass publisher provided identifiers in ad request (PPID) (Only for GAM)

1

Create your AdRequestConfiguration

Java / Kotlin:

Java
AdRequestConfiguration.Builder configuration = AdRequestConfiguration.Companion.builder(context, "Your_placement_name");
2

Add PPID to the AdRequest

Set the publisher-provided identifier on the configuration:

Java / Kotlin
configuration.publisherProvidedId("YOUR_PPID");
circle-info

hashta g

PPID can be passed for all ad type ad requests. See: https://docs.adster.tech/feature-only-for-gam/how-to-pass-publisher-provided-identifiers-in-ad-request-ppid-only-for-gam#ppid-can-be-passed-for-all-a-d-type-ad-requests

3

Load a banner ad (example implementation)

Build the AdSterAdLoader with listeners and call loadAd(configuration.build()). Java and Kotlin examples are shown.

Java
AdSterAdLoader.Companion.builder().withAdsListener(new MediationAdListener() {
    @Override
    public void onBannerAdLoaded(@NonNull MediationBannerAd ad) {
        super.onBannerAdLoaded(ad);
        // Show banner ad here
    }

    @Override
    public void onFailure(@NonNull AdError adError) {
        // Handle failure here
    }
}).withAdsEventsListener(new AdEventsListener() {
    @Override
    public void onAdClicked() {
        //Handle ad click here
    }

    @Override
    public void onAdImpression() {
        //Handle ad impression here
    }

    @Override
    public void onAdRevenuePaid(double revenue, @NotNull String adUnitId, @NotNull String network) {
        // Callback which provides revenue and the network which provided it
    }
}).build().loadAd(configuration.build());
4

Add the banner view to your layout

Inside the onBannerAdLoaded callback, invoke getView() on the MediationBannerAd object and add it to your container:

Java / Kotlin
container.removeAllViews();
container.addView(ad.getView());
5

Clean up when destroyed

Call MediationBannerAd.destroy() when the activity/fragment is destroyed or detached to release resources.