Skip to content

Adform Native Mediation Adapter

rprunskas edited this page Aug 19, 2025 · 3 revisions

📘 Adform Native Mediation Adapter Integration Guide

This guide explains how to integrate the Adform Native Mediation Adapter into your Android project, using OpenRTB for loading native ads via Google Mobile Ads mediation.

Requirements

Android API level 21+ Google Mobile Ads SDK (v21+ recommended) Mediation Adapter integrated in the mediation waterfall

🚀 Integration Steps

1. Add the Header Bidding SDK(includes mediation adapter) to Your Project

Maven/Gradle:

repositories { maven { url "https://github.com/adform/adform-android-sdk/raw/master/releases/" } }

implementation 'com.adform:adform-header-bidding-sdk:2.21.0'

2. Configure Admob mediation

For a full guide on how to set up mediation in AdMob, refer to the official documentation:

Set up mediation in AdMob

You would need to set up Custom Events manually in your mediation configuration, use the fully qualified class name of the adapter: com.adform.sdk.network.nativead.AdformNativeAdapter

In the AdMob mediation network UI, configure the parameter value with: id=<request_id>,tagid=<tag_id> For example: id=1234,tagid=567890

3. Implement AdMob native ads.

Here is a guide how to implement AdMob native ads: Native AdMob ads setup in android

🔧 Optional: Custom Adapter Extension for Native Asset Changes

If you want to customize which native assets are requested or how they are mapped, you can subclass AdformNativeAdapter and override key methods:

Steps:

  1. Subclass the Adapter
public class CustomAdformNativeAdapter extends AdformNativeAdapter {
    
    @Override
    protected OpenRTBRequest.Native createNativeAdRequest() {
        // Create your custom native ad request with different assets or requirements
        OpenRTBRequest.Native nativeAd = new OpenRTBRequest.Native();
        OpenRTBRequest.NativeRequest nativeRequest = new OpenRTBRequest.NativeRequest();

        // Example: request only title and main image
        OpenRTBRequest.NativeRequestAsset assetTitle = new OpenRTBRequest.NativeRequestAsset();
        assetTitle.id = 1;
        assetTitle.required = 1;
        assetTitle.title = new OpenRTBRequest.RequestTitleAsset();
        assetTitle.title.len = 100;

        OpenRTBRequest.NativeRequestAsset assetMainImage = new OpenRTBRequest.NativeRequestAsset();
        assetMainImage.id = 0;
        assetMainImage.required = 1;
        assetMainImage.img = new OpenRTBRequest.RequestImgAsset();
        assetMainImage.img.hmin = 200;
        assetMainImage.img.wmin = 300;
        assetMainImage.img.type = 3;

        nativeRequest.assets = new ArrayList<>();
        nativeRequest.assets.add(assetTitle);
        nativeRequest.assets.add(assetMainImage);

        nativeAd.request = nativeRequest;
        return nativeAd;
    }
}
  1. Register your custom adapter class name in mediation configuration or custom event:

Please use com.yourpackage.CustomAdformNativeAdapter instead of com.adform.sdk.network.nativead.AdformNativeAdapter

Clone this wiki locally