Custom Targeting
When requesting an ad, you can provide key-value pairs to the ad server so it can return ads more relevant to the page’s content.
For example, if the page is displaying information about a pair of shoes, you could pass relevant keywords about this item to help the ad server return more relevant ads.
iOS
let targeting =
let params = FuseAdViewParams(
customTargeting: [
"brand": "nike",
"category": "shoes",
]
)
// Banner ad
let adView = FuseAdView(code: "<zone_code>", params: params)
// Full-screen ad
let adView = FuseFullScreenAdView(code: code, params: params)
Android
val params = FuseAdViewParams.Builder()
.setCustomTargeting(mapOf(
"brand" to listOf("nike"),
"category" to listOf("shoes"),
))
.build()
// Banner ad
val adView = FuseAdView(context, code = "<zone_code>", params = params)
// Full-screen ad
val adView = FuseFullScreenAdView(context, "<zone_code>", params)
NOTE: You cannot set content custom targeting on FuseAdView
created in XML.
Dynamic Ad Unit ID
Dynamic GAM ad unit IDs can be enabled using custom targeting.
For example, let’s assume an account is configured with the following GAM path template:
/21775744923/banner/${level1}/${level2}
If a FuseAdView
/FuseFullScreenAdView
object sets custom targeting for the keys "level1"
and "level2"
, then the Fuse App SDK will automatically generate a dynamic GAM ad unit ID using those custom targeting values.
For example:
let params = FuseAdViewParams(
customTargeting: [
"level1": "jobs",
"level2": "retail"
]
)
let adView = FuseAdView(code: "<zone-code>", params: params)
// Ad Unit ID: '/21775744923/banner/jobs/retail'
If the custom targeting values are not set, then the SDK will use the zone code’s GAM ad unit ID by default.