Targeting
PrebidTargeting attaches first-party data to every bid request. All methods are static and return Futures.
Targeting lives in the native Prebid SDK, so it is process-wide: in an add-to-app setup with several Flutter engines, every engine reads and writes the same values.
Keywords
await PrebidTargeting.addUserKeywords({'sports', 'football'});
await PrebidTargeting.addAppKeyword('news');
final keywords = await PrebidTargeting.getUserKeywords();
| Methods | Request field |
|---|---|
addUserKeyword, addUserKeywords, removeUserKeyword, clearUserKeywords, getUserKeywords | user.keywords |
addAppKeyword, addAppKeywords, removeAppKeyword, clearAppKeywords | app.keywords |
First-party data
await PrebidTargeting.addUserExtData(key: 'interests', value: 'cycling');
await PrebidTargeting.updateAppExtData(key: 'section', value: {'sports', 'news'});
await PrebidTargeting.removeAppExtData('section');
| Methods | Request field |
|---|---|
addUserExtData, updateUserExtData, removeUserExtData, clearUserExtData | user.ext.data |
addAppExtData, updateAppExtData, removeAppExtData, clearAppExtData | app.ext.data |
add… appends a value to a key; update… replaces all values of a key.
To send other user.ext keys, set the whole object; the addUserExtData keys still own its data entry when any is set:
await PrebidTargeting.setUserExt({'consented_providers_settings': {'consented_providers': [1, 2]}});
final ext = await PrebidTargeting.getUserExt(); // includes `data`
await PrebidTargeting.setUserExt(null); // clears it
Access control list
Only bidders on the list receive the first-party data above (ext.prebid.data.bidders):
await PrebidTargeting.addBidderToAccessControlList('appnexus');
await PrebidTargeting.removeBidderFromAccessControlList('appnexus');
await PrebidTargeting.clearAccessControlList();
Global OpenRTB config
Arbitrary OpenRTB JSON merged into every request:
await PrebidTargeting.setGlobalOrtbConfig('{"ext":{"prebid":{"debug":1}}}');
The plugin adds its own name and version to that config, so every request says it came from this plugin, next to the native SDK's own source and version:
{"app": {"ext": {"prebid": {"wrapper": {"name": "prebid_mobile_sdk", "version": "1.1.0"}}}}}
initializeSdk sends it even when you set no config, and getGlobalOrtbConfig() leaves it out. Whether bidders see it depends on the Prebid Server version, which may drop app.ext.prebid fields it doesn't know. If your native code also sets the global config, the last call wins and the record may be lost.
For a single ad unit, pass impOrtbConfig to the ad instead; it is merged into that ad's imp. This is also how to set a GPID where there is no dedicated parameter: '{"ext":{"gpid":"/1111/home"}}'.
App information
| Method | Request field |
|---|---|
setPublisherName(String?) | app.publisher.name |
setStoreUrl(String?) | app.storeurl |
setDomain(String?) | app.domain |
setAppName(String?) | app.name, by default the app's label (Android) or bundle display name (iOS); null restores it |
setOmidPartnerName(String?), setOmidPartnerVersion(String?) | source.ext.omidpn, source.ext.omidpv |
Prebid iOS has no app-name or bundle setter, so on iOS setAppName and setBundleName merge {"app":{"name":…,"bundle":…}} into the global OpenRTB config the plugin hands the SDK; getGlobalOrtbConfig() still returns your own JSON. On both platforms an app.name or app.bundle in your global OpenRTB config wins over these setters.
Prebid 3.4 has no setter for app.content.url; send it with setGlobalOrtbConfig('{"app":{"content":{"url":"https://example.com/article"}}}').
| setSourceApp(String?) iOS only | SKAdNetwork sourceapp |
| setItunesId(String?) iOS only | Your app's iTunes ID, needed for SKAdNetwork bids when Info.plist lists SKAdNetworkItems |
| setBundleName(String?) | app.bundle, by default the package name or bundle ID; e.g. to test against a Prebid Server account set up for your production app |
Location
await PrebidMobile.setShareGeoLocation(true);
await PrebidTargeting.setUserLatLng(37.7749, -122.4194);
await PrebidTargeting.setLocationPrecision(2); // decimal places, null = full
setUserLatLng sets user.geo and clearUserLatLng removes it; setShareGeoLocation lets the SDK send the device's location (device.geo) when the app has location permission.
Reading the values
PrebidTargeting has getters for what you set: getAppExtData(), getAccessControlList(), getPublisherName(), getStoreUrl(), getDomain(), getOmidPartnerName(), getOmidPartnerVersion(), getSendSharedId(), getUserLatLng() (a (latitude, longitude) record), getLocationPrecision(), getBundleName(), and getAppKeywords(), getSourceApp() and getItunesId() (iOS), next to the existing consent and keyword getters.
User IDs
External identity providers' IDs and Prebid's SharedID are set on PrebidMobile: see Configuration.