广告定位
定位功能支持传递用户和上下文数据,以展示更相关的广告。 以下是使用当前 Yandex Mobile Ads SDK API 的示例:
对于所有广告格式,使用 AdRequest 与可选 AdTargeting。
横幅广告
插屏和激励广告
使用 AdRequest 定位的示例:
const StickyBannerScreen = () => {
// ... state and layout ...
let adRequest = new AdRequest({
age: '20',
contextQuery: 'context-query',
contextTags: ['context-tag'],
gender: Gender.Male,
location: new Location(55.734202, 37.588063),
});
return (
<BannerView
size={adSize!}
adUnitId={selectedAdNetwork?.adUnitId!}
adRequest={adRequest}
/>
);
};
使用 loadAd 定位的示例:
const loadAd = async () => {
let loader = await InterstitialAdLoader.create()
.catch((error) => {
logger.addLog(`Did fail to create the loader with error: ${error}`, setLogs);
setIsButtonDisabled(false);
return;
});
await loader.loadAd({
adUnitId: adUnitId,
targeting:{
age: '20',
contextQuery: 'context-query',
contextTags: ['context-tag'],
gender: Gender.Female,
location: new Location(55.734202, 37.588063),
},
})
.then((ad) =>{
logger.addLog('Did load', setLogs);
setAd(ad);
setButtonLabel('Show ad');
setIsButtonDisabled(false);
})
.catch((error) => {
logger.addLog(`Did fail to load with error: ${error}`, setLogs);
setAd(undefined);
setButtonLabel('Load ad');
setIsButtonDisabled(false);
});
};
|
参数 |
描述 |
|
|
用户年龄:字符串格式的数字(例如“14”、“18”等)。 |
|
|
用户性别:“男性”、“女性”。 您可以使用 |
|
|
用户位置由应用确定。 在使用此功能之前,请确保获得用户同意,并在 SDK 中设置 |
|
|
用户在应用中的搜索查询。 |
|
|
用户正在查看的页面中的关键字。 |