Skip to main content

Advanced Settings

Logs

BidMachine SDK provides a set of logging options to help you debug and monitor the SDK's behavior. You can enable or disable different types of logs, such as general logs, bid logs, and event logs.

BidMachine.setLoggingEnabled(Boolean)

Test Mode

BidMachine SDK can be configured to run in test mode, which is useful for testing and debugging purposes.

BidMachine.setTestMode(Boolean)
warning

Test mode should be disabled in production.

Endpoint

Set your endpoint before initialization if required:

BidMachine.setEndpoint(String)

Location

SDK can automatically track user device location to serve better ads. To make it work for Android 6.0, you should request android.permission.ACCESS_COARSE_LOCATION and android.permission.ACCESS_FINE_LOCATION:

ActivityCompat.requestPermissions(Activity, arrayOf<String>(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
), REQ_CODE)

Publisher Parameters

To pass information about the publisher, use the public method:

BidMachine.setPublisher(Publisher?)
ParamTypeDescription
IdStringPublisher ID
NameStringPublisher name
DomainStringPublisher domain
CategoryStringPublisher content category

Code Example:

val publisher = Publisher.Builder()
.setId(String?)
.setName(String?)
.setDomain(String?)
.addCategory(String?)
.addCategories(List<String>?)
.build()

// Sets publisher information
BidMachine.setPublisher(publisher)

Targeting Parameters

Code Example:

val targetingParams = TargetingParams()
.setUserId(String?)
.setGender(Gender?)
.setBirthdayYear(Int?)
.setKeywords(vararg String?)
.setDeviceLocation(Location?)
.setCountry(String?)
.setCity(String?)
.setZip(String?)
.setStoreUrl(String?)
.setStoreCategory(String?)
.setStoreSubCategories(vararg String?)
.setFramework(String?)
.setPaid(Boolean?)
.setExternalUserIds(List<ExternalUserId>?)
.addBlockedAdvertiserIABCategory(String)
.addBlockedAdvertiserDomain(String)
.addBlockedApplication(String)

TargetingParams can be passed with 2 ways:

  • Through global parameters:
BidMachine.setTargetingParams(targetingParams)
  • Through ad request builder:
adRequestBuilder.setTargetingParams(targetingParams)

You can combine global parameters with regular. If you set Global TargetingParams using UserId, and then make a request using TargetingParams with Gender set, both requests will be merged and the resulting TargetingParams will include both UserId and Gender.

tip

Priority is given to the AdRequest parameters.

Price Floor Parameters

ParameterTypeDescription
IdStringUnique floor identifier.
PricedoubleFloor price

If you use the method with only Price provided PriceFloorParams.addPriceFloor(Double), the Id will be generated using UUID.randomUUID().

Code Example:

val priceFloorParams = PriceFloorParams()
// Set Bid Price, in this case id will be generated
.addPriceFloor(Double)
// Set Bid Id and Price
.addPriceFloor(String, Double)

To set up price floor parameters for ad request use setPriceFloorParams method from AdRequest builder according to ads type.

adRequestBuilder.setPriceFloorParams(priceFloorParams)

Session Parameters

TODO:// Is it stll actual?

Code Example:

val sessionAdParams = SessionAdParams()
.setSessionDuration(Integer?)
.setImpressionCount(Integer?)
.setClickRate(Float?)
.setIsUserClickedOnLastAd(Boolean?)
.setCompletionRate(Float?)

To set up session ad parameters for ad request use setSessionAdParams method from AdRequest builder according to ads type.

adRequestBuilder.setSessionAdParams(sessionAdParams)

Custom Parameters

Code Example:

val customParams = CustomParams()
.addParam(String, String)
.addParams(Map<String, String>)

To set up custom parameters for ad request use setCustomParams method from AdRequest builder according to ads type.

adRequestBuilder.setCustomParams(customParams)

Placement Id

To set up placement id for current impression use setPlacementId method from AdRequest builder according to ads type.

adRequestBuilder.setPlacementId(String?)

Bid Payload

To set up bid payload for ad request use setBidPayload method from AdRequest builder according to ads type.

adRequestBuilder.setBidPayload(String?)
Example

Auction Info

You can get AuctionResult in two ways:

  • Through AdRequestListener. Use AuctionResult from onRequestSuccess callback
adRequestBuilder.setListener(object : <AdRequestObject>.AdRequestListener {
override fun onRequestSuccess(adRequest: <AdRequestObject>,
auctionResult: AuctionResult) {
// Use AuctionResult from onRequestSuccess callback
}
});
  • Through getter. Each AdRequest has an option to retrieve auction result information after it has been loaded.
adRequest.auctionResult

// TODO: Ad auction result fields monitoring

Win/Loss notifications

Call notifyMediationWin/notifyMediationLoss on the AdRequest instance when BidMachine wins/loses the mediation among networks.

  • Win notification:
adRequest.notifyMediationWin()
  • Loss notification:
adRequest.notifyMediationLoss("<WINNER_NETWORK_NAME>", <WINNER_NETWORK_PRICE>)
// or
adRequest.notifyMediationLoss()

Bid Token

With S2S integration, you will need a BidToken that you need to transfer in the request. To get a BidToken, you can use one of 2 methods:

// Must be run on background thread
val bidToken = BidMachine.getBidToken(Context, AdsFormat?)

or

BidMachine.getBidToken(Context, AdsFormat?) { bidToken ->
// The BidToken will be returned on a background thread
}

Server Extras

You can get the configuration from the BM server using a pre-agreed key from the server extra parameters.

val param: Any? = BidMachine.getExtrasParam(Context, String)