LogoLogo
  • Getting started
  • Migration guide
  • Test your implementation
  • Release notes
  • Ad Formats
    • Interstitial
    • Rewarded
    • Small Banner / MREC
    • Thumbnail
  • Privacy
    • Privacy compliance
  • Help
    • Help center
Powered by GitBook
On this page
  • Prerequisites
  • Step 1: Create a Small Banner / MREC ad unit
  • Step 2: Load a Small Banner / MREC
  • Step 3: Register for callbacks
  • Step 3: Show a Small Banner / MREC ad
  • Step 4: Destroying the Small Banner / MREC ad
  • Step 5: Test your integration
  • Advanced topics
  • Error handling

Was this helpful?

  1. Ad Formats

Small Banner / MREC

This article will go through all the steps required to display banner ads in your application.

Last updated 7 months ago

Was this helpful?

Ogury offers two banner sizes that can fit specific positions on the screen and can be seamlessly integrated within your application's content:

  • Small Banner (320x50)

  • MREC (300x250)

Prerequisites

Ensure you have registered your application on the Ogury Dashboard. If not, please refer to the page before proceeding.

Step 1: Create a Small Banner / MREC ad unit

  • on your asset page in the Ogury Dashboard.

  • , as you will need it for integration. It is in the form of a UUID, which consists of a 36-character string formatted as follows: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where each x represents a hexadecimal digit.

In the following code samples, this ad unit ID will be represented as xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Step 2: Load a Small Banner / MREC

To load a Small Banner or MREC ad, instantiate an OguryBannerAdView object with the right size (SMALL_BANNER_320x50 or MREC_300x250) and call its load() method.

class MyActivity : Activity() {

    private lateinit var bannerAd: OguryBannerAdView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        bannerAd = OguryBannerAdView(
            this,
            "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            OguryBannerAdSize.SMALL_BANNER_320x50 // or MREC_300x250 size for MREC ads.
        )
        
        bannerAd.load() 
    }
}
public class MyActivity extends Activity {

    private OguryBannerAdView bannerAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        bannerAd = new OguryBannerAdView(
            this,
            "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            OguryBannerAdSize.SMALL_BANNER_320x50 // or MREC_300x250 size for MREC ads.
        );
        bannerAd.load(); 
    }  
}

OguryBannerAdView requires the following parameters:

  • size: Specifies the banner size, determining whether the ad is a Small Banner (320x50) or MREC (300x250). This parameter is of type OguryBannerAdSize, an enum with values SMALL_BANNER_320x50 and MREC_300x250.

Make sure the ad unit ID you provide matches the size you select.

If you are developing a mediation adapter, you must pass an additional parameter, OguryMediation which should be instantiated with:

  • name: the name of the mediation.

  • version: the version of the mediation SDK.

bannerAd = OguryBannerAdView(
    this,
    "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    OguryBannerAdSize.SMALL_BANNER_320x50, // or MREC_300x250 size for MREC ads.
    OguryMediation("your mediation name", "your mediation SDK version")
)
bannerAd = new OguryBannerAdView(
    this,
    "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    OguryBannerAdSize.SMALL_BANNER_320x50, // or MREC_300x250 size for MREC ads.
    new OguryMediation("your mediation name", "your mediation SDK version")
)

Step 3: Register for callbacks

You can monitor the lifecycle of your Small banner / MREC ad by implementing the OguryBannerAdViewListener interface. This delegate provides real-time updates on key events, such as successful ad loading, display, or errors.

To use it, set the listener on the instance of OguryBannerAdView by calling the setListener() method before invoking the load() method. Implement the necessary methods in your class to ensure timely notifications, allowing you to manage the ad experience effectively.

bannerAd.setListener(object : OguryBannerAdViewListener {

    // Called when the ad is loaded and ready to be shown
    override fun onAdLoaded(bannerAd: OguryBannerAdView) {
        // Attach the ad view to one of your application's view to display the ad
    }

    // Called when an impression is recorded
    override fun onAdImpression(bannerAd: OguryBannerAdView) {
        // Track ad performance here
    }

    // Called when the user clicks on the ad
    override fun onAdClicked(bannerAd: OguryBannerAdView) {
        // Handle ad click tracking here
    }

    // Called when the ad is closed
    override fun onAdClosed(bannerAd: OguryBannerAdView) {
        // Resume app flow after ad is closed
    }

    // Called when the ad fails to load or display
    override fun onAdError(bannerAd: OguryBannerAdView, error: OguryAdError) {
        when (error.type) {
            OguryAdError.Type.LOAD_ERROR -> {
                // Handle loading error
            }
            OguryAdError.Type.SHOW_ERROR -> {
                // Handle display error
            }
        }
    }
})
bannerAd.setListener(new OguryBannerAdViewListener() {

    // Called when the ad is loaded and ready to be shown
    @Override
    public void onAdLoaded(OguryBannerAdView bannerAd) {
        // Attach the ad view to one of your application's view to display the ad
    }

    // Called when an impression is recorded
    @Override
    public void onAdImpression(OguryBannerAdView bannerAd) {
        // Track ad performance here
    }

    // Called when the user clicks on the ad
    @Override
    public void onAdClicked(OguryBannerAdView bannerAd) {
        // Handle ad click tracking here
    }

    // Called when the ad is closed
    @Override
    public void onAdClosed(OguryBannerAdView bannerAd) {
        // Resume app flow after ad is closed
    }

    // Called when the ad fails to load or display
    @Override
    public void onAdError(OguryBannerAdView bannerAd, OguryAdError error) {
        switch (error.getType()) {
            case OguryAdError.Type.LOAD_ERROR:
                // Handle loading error
                break;
            case OguryAdError.Type.SHOW_ERROR:
                // Handle display error
                break;
        }
    }
});

Step 3: Show a Small Banner / MREC ad

To display a Small Banner or MREC ad, you simply need to attach the instance of OguryBannerAdView to one of your view.

if (bannerAd.isLoaded()) {
    // The ad is loaded and ready to be displayed.
    yourView.removeAllViews()
    yourView.addView(bannerAd)
} else {
    // The ad is not loaded yet. Handle this situation appropriately.
}
if (bannerAd.isLoaded()) {
    // The ad is loaded and ready to be displayed.
    yourView.removeAllViews();
    yourView.addView(bannerAd);
} else {
    // The ad is not loaded yet. Handle this situation appropriately.
}

We recommend to attach the Small Banner or MREC ad once it is loaded. Use the onAdLoaded callback to receive real-time notifications when the ad is ready.

Step 4: Destroying the Small Banner / MREC ad

The Small Banner and MREC ads are automatically destroyed when your Activity or Fragment is terminated. If you need to manually destroy it, call the destroy method as follows:

bannerAd.destroy()
bannerAd.destroy();

Step 5: Test your integration

After registering your app, it may take up to 15 minutes before ads are available.

Since our algorithm uses personalized targeting, you may not receive ads during testing. To obtain test ads, you can append _test to your Small Banner / MREC ad unit ID in the code, for example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_test.

Advanced topics

Error handling

If you are unable to load or display any Small Banner or MREC ads, we recommend logging callbacks from the OguryBannerAdViewListener to monitor the ad's lifecycle, especially the onAdError callback. This method provides an OguryAdError instance containing important error details:

  • type: indicates the error type through the OguryAdError.Type enum, which distinguishes between loading errors (Load) and showing errors (Show).

  • code: An integer that identifies the specific error. Errors that can occur during ad loading or displaying are defined in the OguryLoadErrorCode and OguryShowErrorCode classes. Detailed explanations of these error codes are provided in the tables below to assist you in troubleshooting effectively.

  • message: A descriptive message that provides additional context about the error.

You can utilize these details to diagnose the issue and take appropriate action to resolve it.

OguryLoadErrorCode

Enum value
Description

SDK_NOT_STARTED

The load could not proceed because the SDK appears to have not been started.

SDK_NOT_PROPERLY_INITIALIZED

The load could not proceed because the SDK is not properly initialized.

NO_ACTIVE_INTERNET_CONNECTION

The load could not proceed because there is no active Internet connection.

INVALID_CONFIGURATION

The load could not proceed due to an invalid SDK configuration.

AD_DISABLED_COUNTRY_NOT_OPENED

The load could not proceed because ads are disabled; the user’s country is not yet available for advertising.

AD_DISABLED_CONSENT_DENIED

The load could not proceed because ads are disabled; the user has denied consent for advertising.

AD_DISABLED_CONSENT_MISSING

The load could not proceed because ads are disabled; the user consent is missing or has not been provided.

AD_DISABLED_UNSPECIFIED_REASON

The load could not proceed because ads are disabled for an unspecified reason.

AD_REQUEST_FAILED

The load failed because the ad request encountered an error, and the server returned an unexpected response.

NO_FILL

No ad is currently available for this placement (no fill).

AD_PARSING_FAILED

The ad could not be loaded due to a failure in parsing.

AD_PRECACHING_FAILED

The ad could not be loaded due to a failure in ad precaching.

AD_PRECACHING_TIMEOUT

The ad could not be loaded as precaching exceeded the time limit and timed out.

OguryShowErrorCode

Enum value
Description

SDK_NOT_STARTED

The ad could not be displayed because the SDK appears to have not been started.

SDK_NOT_PROPERLY_INITIALIZED

The ad could not be displayed because the SDK is not properly initialized.

NO_ACTIVE_INTERNET_CONNECTION

The ad could not be displayed because there is no active Internet connection.

INVALID_CONFIGURATION

The ad could not be displayed due to an invalid SDK configuration.

AD_DISABLED_COUNTRY_NOT_OPENED

The ad could not be displayed because ads are disabled; the user’s country is not yet available for advertising.

AD_DISABLED_CONSENT_DENIED

The ad could not be displayed because ads are disabled; the user has denied consent for advertising.

AD_DISABLED_CONSENT_MISSING

The ad could not be displayed because ads are disabled; the user consent is missing or has not been provided.

AD_DISABLED_UNSPECIFIED_REASON

The ad could not be displayed because ads are disabled for an unspecified reason.

AD_EXPIRED

The ad could not be displayed because the retention time of the loaded ad has expired.

NO_AD_LOADED

No ad has been loaded.

VIEW_IN_BACKGROUND

The ad could not be displayed because the application was running in the background.

ANOTHER_AD_ALREADY_DISPLAYED

The ad could not be displayed because another ad is currently being displayed.

WEBVIEW_TERMINATED_BY_SYSTEM

The ad could not be displayed because the WebView was terminated by the system, resulting in the ad being unloaded due to high resource consumption by the application.

adUnitID: the ad unit ID for the Small Banner or MREC ad. If you do not have one, please refer to the to create it.

If the onAdErrorcallback is triggered, refer to the section below for detailed information on troubleshooting.

Ogury exclusively serves ads to users who have provided their consent. Before conducting any tests, it is essential to ensure that your implementation complies with applicable privacy regulations. For more information on the regulations supported by Ogury, please visit the page.

For further details on test mode and enabling debug logs, please refer to the page.

Privacy compliance
Test your implementation
first step
Error handling
Getting Started
Create a Small Banner or MREC ad unit
Copy the ad unit ID