Price Genius inApp implementation
Last edited: 2024/05/09
Implementation instructions
Android
Integration with Price genius requires adding custom targeting to AdManager AdRequest Builder, and adding a method that returns key values.
Java version
You can pass custom key-value pairs to target Google Ad Manager campaigns (line items) through:
.addCustomTargeting("yb_ab", getKeyValue())
an example of simple AdRequest Builder with custom targeting:
AdManagerAdRequest adRequest = new AdManagerAdRequest.Builder()
.addCustomTargeting("yb_ab", getKeyValue())
.build();
Method that returns key values:
private String getKeyValue(){
int param = (int) (Math.abs((System.currentTimeMillis())) % 1000);
if(param < 100) return "c";
else if (param > 909) return "a" + param % 10;
return "b";
Kotlin version
You can pass custom key-value pairs to target Google Ad Manager campaigns (line items) through:
.addCustomTargeting("yb_ab", getKeyValue())
an example of simple AdRequest Builder with custom targeting:
val adRequest = AdManagerAdRequest.Builder()
.addCustomTargeting("yb_ab", getKeyValue())
.build()
Method that returns key values:
private fun getKeyValue(): String {
val param = abs(System.currentTimeMillis()) % 1000
if (param < 100) {
return "c"
} else if (param > 909) {
return "a" + param % 10
}
return "b"
}
iOS
Integration with PriceGenius requires adding custom targeting to GAMRequest, and adding a method that returns key values.
You can pass custom key-value pairs to target Google Ad Manager campaigns (line items) through:
.customTargeting = ["yb_ab":getKeyValues()]
an example of simple GAMRequest with custom targeting:
let request = GAMRequest()
request.customTargeting = ["yb_ab":getKeyValues()]
Method that returns key values:
func getKeyValues() -> String{
let param = Int.random(in: 1..<1000)
if(param < 100) {
return "c"
} else if(param > 909){
let variant = param % 10
return "a\(variant)"
}
return "b"
}