Advanced Settings
Global 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.
- Java
- Kotlin
BidMachine.setLoggingEnabled(boolean);
BidMachine.setLoggingEnabled(Boolean)
Test Mode
BidMachine SDK can be configured to run in test mode, which is useful for testing and debugging purposes.
- Java
- Kotlin
BidMachine.setTestMode(boolean);
BidMachine.setTestMode(Boolean)
Test mode should be disabled in production.
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:
- Java
- Kotlin
ActivityCompat.requestPermissions(@NonNull Activity, new String[]{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
}, REQ_CODE);
ActivityCompat.requestPermissions(Activity, arrayOf<String>(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
), REQ_CODE)
Publisher Parameters
The publisher info is used to provide information about the publisher of the app. This information is used for targeting and reporting purposes.
- Java
- Kotlin
BidMachine.setPublisher(@Nullable Publisher);
BidMachine.setPublisher(Publisher?)
| Param | Type | Description |
|---|---|---|
| Id | String | Publisher ID |
| Name | String | Publisher name |
| Domain | String | Publisher domain |
| Category | String | Publisher content category |
Code Example:
- Java
- Kotlin
Publisher publisher = new Publisher.Builder()
.setId(@Nullable String)
.setName(@Nullable String)
.setDomain(@Nullable String)
.addCategory(@Nullable String)
.addCategories(@Nullable List<String>)
.build();
// Sets publisher information
BidMachine.setPublisher(publisher);
val publisher = Publisher.Builder()
.setId(String?)
.setName(String?)
.setDomain(String?)
.addCategory(String?)
.addCategories(List<String>?)
.build()
// Sets publisher information
BidMachine.setPublisher(publisher)
Targeting Parameters
The targeting info is used to provide information about the user and the app.
- Java
- Kotlin
TargetingParams targetingParams = new TargetingParams()
.setUserId(@Nullable String)
.setGender(@Nullable Gender)
.setBirthdayYear(@Nullable Integer)
.setKeywords(@Nullable String[])
.setDeviceLocation(@Nullable Location)
.setCountry(@Nullable String)
.setCity(@Nullable String)
.setZip(@Nullable String)
.setStoreUrl(@Nullable String)
.setStoreCategory(@Nullable String)
.setStoreSubCategories(@Nullable String[])
.setFramework(@Nullable String)
.setPaid(@Nullable Boolean)
.setExternalUserIds(@Nullable List<ExternalUserId>)
.addBlockedAdvertiserIABCategory(@NonNull String)
.addBlockedAdvertiserDomain(@NonNull String)
.addBlockedApplication(@NonNull String);
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:
- Java
- Kotlin
BidMachine.setTargetingParams(targetingParams);
BidMachine.setTargetingParams(targetingParams)
- Through ad request builder:
- Java
- Kotlin
adRequestBuilder.setTargetingParams(targetingParams);
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.
Priority is given to the AdRequest parameters.
Auction Request Settings
Price Floor Parameters
The price floor info is used to set a minimum price for the ad unit, you can pass multiple price floors for one ad request.
The price floor is always in the US dollars.
If you use the method with only Price provided PriceFloorParams.addPriceFloor(Double),
the Id will be generated using UUID.randomUUID().
- Java
- Kotlin
PriceFloorParams priceFloorParams = new PriceFloorParams()
// Set Bid Price, in this case id will be generated
.addPriceFloor(double)
// Set Bid Id and Price
.addPriceFloor(@NonNull String, double);
val priceFloorParams = PriceFloorParams()
// Set Bid Price, in this case id will be generated
.addPriceFloor(Double)
// Set Bid Id and Price
.addPriceFloor(String, Double)
| Parameter | Type | Description |
|---|---|---|
| Id | String | Unique floor identifier. |
| Price | double | Floor price |
To set up price floor parameters for ad request use setPriceFloorParams method from AdRequest builder according to ads type.
- Java
- Kotlin
adRequestBuilder.setPriceFloorParams(priceFloorParams);
adRequestBuilder.setPriceFloorParams(priceFloorParams)
Placement Settings
Custom Parameters
You can pass custom parameters in the placement object to be sent to the server. Custom parameters is a dictionary of key-value pairs that can be used for targeting or reporting purposes.
- Java
- Kotlin
CustomParams customParams = new CustomParams()
.addParam(@NonNull String, @NonNull String)
.addParams(@NonNull Map<String, String>);
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.
- Java
- Kotlin
adRequestBuilder.setCustomParams(customParams);
adRequestBuilder.setCustomParams(customParams)
Auction Info
The auction info provides details about the ad auction, including bid ID, creative ID, deal ID, campaign ID, demand source, price, and custom parameters.
You can get AuctionResult in two ways:
- Through
AdRequestListener. UseAuctionResultfromonRequestSuccesscallback
- Java
- Kotlin
adRequestBuilder.setListener(new <AdRequestObject>.AdRequestListener() {
@Override
public void onRequestSuccess(@NonNull <AdRequestObject> adRequest,
@NonNull AuctionResult auctionResult) {
// 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
AdRequesthas an option to retrieve auction result information after it has been loaded.
- Java
- Kotlin
adRequest.getAuctionResult();
adRequest.auctionResult
| Parameter | Type | Description | Sample |
|---|---|---|---|
| Id | String | Winner bid ID provided in the request. | cc5bd14b-aaef-4037-b4f8-879913366e3c |
| Demand Source | String | Winner advertising source name. | BidMachine Test |
| Price | double | Winner price expressed as CPM. | 0.023 |
| Deal | String | Id of Price Floor. | d6f61bf9-11a8-4172-a77d-4b1ff85a727f |
| Creative Id | String | Winner creative id. | 123.13579 |
| CID | String | Winner Campaign ID or other similar grouping of brand-related ads. | 123.13587 |
| Ad Domain | Array of String | Winner advertiser domain (top two levels only, e.g., “ford.com”). | ["sample1.com", "sample2.com"] |
| Network Key | String | Winner network key. This network will be loaded. | mraid |
| Network Params | Map, String - String | Client parameters of winner networks. | — |
| Creative Format | Enum | CreativeFormat, one of: Banner, Video, Native. | CreativeFormat.Video |
| Custom Params | Map, String - String | Map that contains additional information about the response. | — |
Win/Loss notifications
Call notifyMediationWin/notifyMediationLoss on the AdRequest instance when BidMachine wins/loses the mediation among networks.
- Win notification:
- Java
- Kotlin
adRequest.notifyMediationWin();
adRequest.notifyMediationWin()
- Loss notification:
- Java
- Kotlin
adRequest.notifyMediationLoss("<WINNER_NETWORK_NAME>", <WINNER_NETWORK_PRICE>);
// or
adRequest.notifyMediationLoss();
adRequest.notifyMediationLoss("<WINNER_NETWORK_NAME>", <WINNER_NETWORK_PRICE>)
// or
adRequest.notifyMediationLoss()