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.
- 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.
Endpoint
Set your endpoint before initialization if required:
- Java
- Kotlin
BidMachine.setEndpoint(@NonNull String);
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
:
- 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
To pass information about the publisher, use the public method:
- 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
Code Example:
- 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.
Price Floor Parameters
Parameter | Type | Description |
---|---|---|
Id | String | Unique floor identifier. |
Price | double | Floor price |
If you use the method with only Price provided PriceFloorParams.addPriceFloor(Double)
,
the Id will be generated using UUID.randomUUID()
.
Code Example:
- 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)
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)
Session Parameters
TODO:// Is it stll actual?
Code Example:
- Java
- Kotlin
SessionAdParams sessionAdParams = new SessionAdParams()
.setSessionDuration(@Nullable Integer)
.setImpressionCount(@Nullable Integer)
.setClickRate(@Nullable Float)
.setIsUserClickedOnLastAd(@Nullable Boolean)
.setCompletionRate(@Nullable Float);
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.
- Java
- Kotlin
adRequestBuilder.setSessionAdParams(sessionAdParams);
adRequestBuilder.setSessionAdParams(sessionAdParams)
Custom Parameters
Code Example:
- 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)
Placement Id
To set up placement id for current impression use setPlacementId
method from AdRequest
builder according to ads type.
- Java
- Kotlin
adRequestBuilder.setPlacementId(@Nullable String);
adRequestBuilder.setPlacementId(String?)
Bid Payload
To set up bid payload for ad request use setBidPayload
method from AdRequest
builder according to ads type.
- Java
- Kotlin
adRequestBuilder.setBidPayload(@Nullable String);
adRequestBuilder.setBidPayload(String?)
Auction Info
You can get AuctionResult
in two ways:
- Through
AdRequestListener
. UseAuctionResult
fromonRequestSuccess
callback
- 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
AdRequest
has an option to retrieve auction result information after it has been loaded.
- Java
- Kotlin
adRequest.getAuctionResult();
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:
- 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()
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:
- Java
- Kotlin
// Must be run on background thread
String bidToken = BidMachine.getBidToken(@NonNull Context, @Nullable AdsFormat);
// Must be run on background thread
val bidToken = BidMachine.getBidToken(Context, AdsFormat?)
or
- Java
- Kotlin
BidMachine.getBidToken(@NonNull Context, @Nullable AdsFormat, new BidTokenCallback() {
@Override
public void onCollected(@NonNull String bidToken) {
// The BidToken will be returned on a background thread
}
});
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.
- Java
- Kotlin
Object param = BidMachine.getExtrasParam(@NonNull Context, @NonNull String);
val param: Any? = BidMachine.getExtrasParam(Context, String)