Madex
  • Android SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • iOS SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • Unity Plugin
    • Installing and configuring the plugin
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change log
  • Cordova Plugin
    • Installation and configuration the plugin
    • Working with advertising
    • Change Log
  • Construct3 Addon
    • Addon installation and configuration
    • Installation and configuration of Madex mediation addon
    • Working with advertising
Powered by GitBook
On this page
  • Identifiers from personal account
  • Publisher identifier (publisher_id)
  • Ad unit identifier (placement_name)
  • Test identifiers
  • Advertising Formats
  • Fullscreen Banner (Interstitial)
  • Rewarded Video
  • Banner 320x50
  • Plugin Methods
  • Using Multiple Ad Units
  • Tracking Ad Events
  1. Unity Plugin

Working with advertising

General principle of interaction with ad units.

PreviousInstalling and configuring the pluginNextUser Consent Screen

Last updated 5 days ago

Identifiers from personal account

Publisher identifier (publisher_id)

To initialize the plugin you will need the publisher identifier (publisher_id)

Your publisher_id is located in the "Settings" section of your Madex personal account.

Ad unit identifier (placement_name)

When using plugin methods, you will need the ad unit identifier (placement_name) of the ad unit.

placement_name is the ID of the ad unit. Ad units are created in Madex personal account.

Test identifiers

During plugin integration, we recommend using special publisher_id and placement_name to get stable test ads.

Publisher ID - d42994c6-2145-4269-9c2f-2adcf9d9703f

International format

Madex Interstitial ID - 50f37030-162d-4e8c-a9c0-e078d8fbf2f7

IronSource Interstitial ID - 82e3bba6-6add-4594-8bb7-f96fef5b252d

Rewarded Video Format

Madex Rewarded ID - dacd566d-8487-4bc6-8afc-486f625be870

IronSource Rewarded ID - 42e716e1-91c0-47e0-9832-c36ada6fa836

Banner Format

Madex Banner ID - 901a609e-b9b2-4f82-b8b8-c899c5524867

Advertising Formats

The Madex advertising network supports 2 ad formats.

Fullscreen Banner (Interstitial)

The ad is displayed on the entire screen and contains a banner, interactive banner, or video. Tapping on it leads to a transition to the link specified by the advertiser.

Users can close the banner after 3 seconds.

This format is typically used when launching the application or transitioning between application screens.

When working with this format, use the Madex.Interstitialparameter.

Here's an example method call to display this format of advertising.

Madex.ShowAd(Madex.Interstitial, "placement_name");

Rewarded Video

The ad is displayed on the entire screen and contains a video or interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

Users can stop viewing the ad, but in this case, they will see a dialog warning about the lack of a reward when closing the video before its completion.

When working with this format, use the Madex.Rewarded parameter.

Here's an example method call to display this format of advertising.

Madex.ShowAd(Madex.Rewarded, "placement_name");

To determine whether to reward the user, use the onRewardedFinished event.

Banner 320x50

The ad is displayed at the bottom of the screen and contains an interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

When working with this format, use the Madex.Banner parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(Madex.Banner, "placement_name");

Auto-Refresh of Banner Ads

To increase your profits, we have developed a function for automatic content change in the banner.

To configure, specify the interval in seconds (minimum 10 seconds).

If the parameter is not filled in or equals zero, the content will not be updated.

var settings = new BannerSettings()
    .SetRefreshIntervalSeconds(10);
Madex.SetBannerCustomSettings(settings);

Banner Placement

By default, the banner is positioned at the bottom of the screen, but you can override this behavior.

Define the banner’s position using BannerSettings.

Bottom of the screen:

var settings = new BannerSettings()
    .SetBannerPosition(BannerPosition.BOTTOM);
Madex.SetBannerCustomSettings(settings);

Top of the screen:

var settings = new BannerSettings()
    .SetBannerPosition(BannerPosition.TOP);
Madex.SetBannerCustomSettings(settings);

Show close button

By default, the close banner button is not shown, but you can enable it:

var settings = new BannerSettings()
    .SetShowCloseButton(true);
Madex.SetBannerCustomSettings(settings);

Plugin Methods

Working with ads involves working with Madex Plugin methods.

  1. initialize (required): Initializes the plugin . It's sufficient to call this method once at the application launch or before the first call to the loadAd method.

Madex.Initialize("publisher_id");

  1. loadAd (required): Loads ads from the server. Usually, this method is called in advance so that the content is loaded by the time of the ad display. In this case, the user's waiting time for ad display will be minimal.

// Load Interstitial ad
Madex.LoadAd(Madex.Interstitial, "placement_name");
// Load Rewarded video ad
Madex.LoadAd(Madex.Rewarded, "placement_name");
// Load Banner ad
Madex.LoadAd(Madex.Banner, "placement_name");

  1. isAdLoaded (optional): Checks the ad unit loading status.

Madex.IsAdLoaded(Madex.Interstitial, "placement_name");
Madex.IsAdLoaded(Madex.Rewarded, "placement_name");
Madex.IsAdLoaded(Madex.Banner, "placement_name");

The method returns true or false. If the answer is negative, attempting to show the ad will lead to nothing.

Although the use of this method is optional, we strongly recommend checking the ad loading status before attempting to display it.

// Check the loading status and subsequently show the Interstitial ad
if (Madex.IsAdLoaded(Madex.Interstitial, "placement_name")) {    
    Madex.ShowAd(Madex.Interstitial, "placement_name");
}

  1. showAd (required): Calls ad display using the player built into the plugin.

Madex.ShowAd(Madex.Interstitial, "placement_name");
Madex.ShowAd(Madex.Rewarded, "placement_name");
Madex.ShowAd(Madex.Banner, "placement_name");

  1. destroyAd (optional): Destroys the ad container. You can work with multiple ad units simultaneously, but we strongly recommend destroying unnecessary ones to avoid memory issues and other problems.

// Destroy the Rewarded Video ad container
Madex.DestroyAd(Madex.Rewarded, "placement_name");

Using Multiple Ad Units

You can work with multiple ad units asynchronously, meaning you can call methods with different placement_names and formats independently of each other. For example, you can call the loadAd method for several blocks at once and load them concurrently.

Tracking Ad Events

Madex Plugin allows you to track events occurring with ads to use them for integrating ads into your application's logic.

To track events, you need to provide a class to work with.

Note that ad events work on any ad unit.

That is, if you call the loading of 2 ad units simultaneously, the loading event will work 2 times, once for each unit.

To track events, do the following:

  1. Inherit the class that will handle ad events from the interface to track events.

class YourClassName : IInterstitialAdListener {
    public void OnInterstitialLoaded(AdPayload adPayload)
    {
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnInterstitialLoadFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad loading
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnInterstitialShown(AdPayload adPayload)
    {
       // Called when the ad is displayed
       // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnInterstitialShowFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad display
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnInterstitialClosed(AdPayload adPayload)
    {
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
}
class YourClassName : IRewaredAdListener {
    public void OnRewaredLoaded(AdPayload adPayload)
    {
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnRewardedLoadFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad loading
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnRewaredShown(AdPayload adPayload)
    {
        // Called when the ad is displayed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnRewardedShowFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad display
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnRewaredClosed(AdPayload adPayload)
    {
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnRewardedVideoStarted(AdPayload adPayload)
    {
        // Called when a video ad starts playing
        // Using AdPayload adPayload, you can get detailed information about the request
    }

    public void OnRewardedVideoCompleted(AdPayload adPayload)
    {
        // Called when the advertising video has completed
        // Using AdPayload adPayload, you can get detailed information about the request
    }

    public void OnUserRewarded(AdPayload adPayload)
    {
        // Here you can reward the user
        // Using AdPayload adPayload, you can get detailed information about the request
    }
}
class YourClassName : IBannerAdListener {
    public void OnBannerLoaded(AdPayload adPayload)
    {
        // Called when the ad is loaded
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnBannerLoadFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad loading
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnBannerShown(AdPayload adPayload)
    {
        // Called when the ad is displayed
        // Using AdPayload adPayload, you can get detailed information about the request
    }
    
    public void OnBannerShowFailed(AdPayload adPayload, AdException error)
    {
        // Called if there is an error during ad display
        // Using AdPayload adPayload, you can get detailed information about the request
        // You can obtain detailed error information using AdException error
    }
    
    public void OnBannerClosed(AdPayload adPayload)
    {
        // Called when the ad is closed
        // Using AdPayload adPayload, you can get detailed information about the request
    }

    public void OnBannerImpression(AdPayload adPayload)
    {
        // Recording the banner impression
        // Using AdPayload adPayload, you can get detailed information about the request
    }
}
  1. Link your event tracking class to the Madex Plugin. Usually, the class that works with ads is also the class for tracking events, so you can specify this as the delegate property.

Madex.SetInterstitialCallbacks(this);
Madex.SetRewardedCallbacks(this);
Madex.SetBannerCallbacks(this);

setUserConsent (optional): Intended for conveying the user's consent status for the collection, processing, and use of personal data. By default, it is set to false, meaning the user has not given consent to the use of their data for advertising and other purposes. We recommend using this method to improve ad monetization quality. You can obtain consent on your own or use our .

Consent Manager