Skip to content

Instantly share code, notes, and snippets.

@mjonesjr90
Last active January 14, 2019 14:32
Show Gist options
  • Save mjonesjr90/8a226498d6241074f27fc6ec7f7d4680 to your computer and use it in GitHub Desktop.
Save mjonesjr90/8a226498d6241074f27fc6ec7f7d4680 to your computer and use it in GitHub Desktop.
Super Auction Guidance

Super Auction Guidance

Super Auction gives you access to multiple demand sources at once in real-time. By calling the requestBid API, ONE Mobile will produce a bid response containing ad markup and a bid price. Once you get the bid, you decide what to do with it. Some of your options are:

  • Display the ad
  • Send it to your primary SSP - in many cases this is MoPub or DFP
  • Insert it into your proprietary waterfall

Usage with Proprietary Waterfall

If you have a custom/proprietary waterfall, you need to take our bid response and insert it into your own waterfall. The gist of this will be to call our requestBid API, determine if we return a bid, and if a bid is returned you need to dynamically insert that bid response in your waterfall.

Let's look at a waterfall with Partner A, B, C, and D. The following historic eCPMs apply to these:

  • Partner A: $1.23
  • Partner B: $1.12
  • Partner C: $0.89
  • Partner D: $0.75

When integrating Super Auction, you will now call the requestBid API first - before starting the waterfall.

Example 1

The requestBid API returns a bid price of $1.01. Your waterfall will now look like the following:

  • Partner A
  • Partner B
  • ONE Mobile Super Auction: $1.01
  • Partner C
  • Partner D

In this scenario, if Partner A and B no fill, ONE Mobile Super Auction is guaranteed to fill since we have already returned a bid response with ad markup. You will use our APIs to deliver/load the ad markup.

Example 2

The requestBid API returns a bid price of $1.50. Your waterfall will now look like the following:

  • ONE Mobile Super Auction: $1.50
  • Partner A
  • Partner B
  • Partner C
  • Partner D

In this scenario, ONE Mobile Super Auction will fill at the top of your waterfall since we have already returned a bid response with ad markup and it's greater than the eCPMs of your other partners. You will use our APIs to deliver/load the ad markup.

Usage with MoPub

Examples of sending the bid response to MoPub is given below. In these instances, we return a bid response and then pass it to MoPub as a keyword (Android examples given below).

MoPub

moPubView.setKeywords("sa:" + bidPrice);

These keywords then match line items in their respective UIs - this is how bids are dynamically inserted for these platforms.

MoPub Line Item Setup

MoPub - Android - Java

private void requestBidPrice(){
    Log.v(TAG, "REQUESTING BID");
    InlineAd.InlineAdMetadata inlineMetadata = new InlineAd.InlineAdMetadata();
    inlineMetadata.setAdSize(InlineAd.AdSize.BANNER);
        try {
            InlineAd.requestBid(PLACEMENT_ID, inlineMetadata, new BidRequestListener() {
                @Override
                public void onRequestSucceeded(String bidPrice) {
                    // set the bid price as a keyword on the 3rd party SDK ad request
                    moPubView.setKeywords("sa:" + bidPrice); //the keyword can be what you want - in this case it's sa
                    moPubView.loadAd(); //call mopub to load the ad
                    Log.e(TAG, "Passed bid of: " + bidPrice);
                }

                @Override
                public void onRequestFailed(BidRequestErrorStatus errorStatus) {
                    // error handling here - in this case I make a regular MoPub request
                    moPubView.loadAd();
                    Log.e(TAG, "Failed bid; called MoPub without bid");
                }
            });
        } catch (MMException e) {
            Log.e(TAG, "Error getting bid", e);
            // abort loading ad
        }
}

MoPub - iOS - Swift

func loadBannerAd(){
    MMInlineAd.requestBid(forPlacementId: PLACEMENT_ID, adSize: MMInlineAdSize.banner, requestInfo: nil, completion: { (bid: String?, error: Error?) -> Void in
        if bid != nil {
            os_log("ONE Mobile bid of was received. Passing to MoPub", log: OSLog.default, type: .debug)
            self.mpAdView.keywords = "sa:\(String(describing: bid!))"
            self.mpAdView.loadAd()
        } else {
            os_log("ONE Mobile bid request failed", log: OSLog.default,type: .debug)
        }
    })
}

MoPub - iOS - Objective-C

(void) loadBannerAd {
    [MMInlineAd requestBidForPlacementId:@"PLACEMENT_ID"
        adSize:MMInlineAdSizeBanner
        requestInfo:nil
        completion:^(NSString * _Nullable bid, NSError * _Nullable error) {
              if (!error && bid) {
                  NSLog(@"Passed bid: %@", bid);
                  [self.mopubAdView setKeywords:bid];
              }
               // . . .
               [self.mopubAdView loadAd];
          }];
}

Note: These requests are encapsulated in methods/functions, but can be made to suit your app architecture. It also assumes your MoPub view has already been created.

As of January 2019, Google has deprecated SDK Mediation Creatives through DFP. This was a requirement for Super Auction to work. The code is below for archive/reference purposes, but new integrations should not be attempted.

DFP

adRequest = new PublisherAdRequest.Builder().addCustomTargeting("sa", bidPrice).build();

DFP Line Item Setup

DFP - Android - Java

private void requestBidPrice(){
    Log.v(TAG, "REQUESTING BID");
    InlineAd.InlineAdMetadata inlineMetadata = new InlineAd.InlineAdMetadata();
    inlineMetadata.setAdSize(InlineAd.AdSize.BANNER);
        try {
            InlineAd.requestBid(PLACEMENT_ID, inlineMetadata, new BidRequestListener() {
                @Override
                public void onRequestSucceeded(String bidPrice) {
                    // set the bid price as a keyword on the 3rd party SDK ad request
                    adRequest = new PublisherAdRequest.Builder()
                            .addCustomTargeting("sa", bidPrice)
                            .build();
                    Log.v(TAG, "adRequest built");
                    // DFP LoadAd must run on the main UI thread
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            adContainer.loadAd(adRequest);
                        }
                    });
                    Log.e(TAG, "Passed bid of: " + bidPrice);
                }

                @Override
                public void onRequestFailed(BidRequestErrorStatus errorStatus) {
                    // error handling here - in this case I make a regular MoPub request
                    moPubView.loadAd();
                    Log.e(TAG, "Failed bid; called MoPub without bid");
                }
            });
        } catch (MMException e) {
            Log.e(TAG, "Error getting bid", e);
            // abort loading ad
        }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment