19世纪末至20世纪初,传统广告营销模式盛行,通过"包时段、包位置"的采买合约模式,广告主提前数周锁定资源,平台按刊例价结算。然而这种模式存在资源配置不合理、广告主决策滞后和广告投放信息不透明等痛点,为了让平台资源零浪费,广告主出价零盲目,且用户体验零干扰,HarmonyOS SDK广告服务(Ads Kit)提供了实时竞价的能力,帮助广告主在应用平台上实现广告投放利益最大化。
什么是实时竞价
实时竞价是指用户在访问媒体产生曝光机会时,众多家DSP(Demand Side Platform),即需求方平台,根据曝光的上下文以及用户属性实时地评估曝光价值,并给出报价,出价最高的DSP胜出,赢得此次广告曝光机会。
比如,某应用作为广告交易平台的媒体,提供一个广告位,用户访问该媒体页面,即代表一次曝光机会,此时,多家需求方平台可以通过媒体提供的用户属性、使用场景、底价等信息进行报价竞拍,并在100毫秒内完成估价和出价,价高者中标后即可占用该广告位,并向用户展示。
通过实时竞价,无论是平台媒体,还是广告需求方,都可以实现曝光和收益最大化。
如何实现实时竞价
一、添加竞价参数
开发者需要在广告请求参数AdRequestParams中添加实时竞价相关参数。- import { advertising } from '@kit.AdsKit';
- const adRequestParams: advertising.AdRequestParams = {
- // 'testu7m3hc4gvm'为测试专用的广告位ID,暂无竞价信息,App正式发布时需要改为正式的广告位ID
- adId: 'testu7m3hc4gvm',
- // 广告类型
- adType: 3,
- // 交易的最大超时时间
- tMax: 100,
- // 竞价请求支持的币种,多个用英文逗号分隔
- cur: 'CNY',
- // 竞价广告位的底价
- bidFloor: 6.66,
- // 竞价广告位底价使用的币种
- bidFloorCur: 'CNY',
- // 广告位竞投的APP包名,多个用英文逗号分隔
- bpkgName: 'com.huawei.baidu,com.huawei.music'
- };
复制代码 二、处理竞价结果
开发者需要在广告请求成功后的回调AdLoadListener.onAdLoadSuccess或MultiSlotsAdLoadListener.onAdLoadSuccess中,处理广告返回的实时竞价结果Advertisement.biddingInfo。- import { advertising } from '@kit.AdsKit';
- import { hilog } from '@kit.PerformanceAnalysisKit';
- import { rcp } from '@kit.RemoteCommunicationKit';
- interface BiddingInfo {
- // 本条广告的eCPM(每一千次展示可以获得的广告收入)
- price: number;
- // 本条广告的价格币种
- cur: string;
- // 媒体回传竞价成功结果的URL
- nurl: string;
- // 媒体回传竞价失败结果的URL
- lurl: string;
- }
- const adLoaderListener: advertising.AdLoadListener = {
- // 广告请求失败回调
- onAdLoadFailure: (errorCode: number, errorMsg: string) => {
- hilog.error(0x0000, 'testTag', `Failed to load ad. Code is ${errorCode}, message is ${errorMsg}`);
- },
- // 广告请求成功回调
- onAdLoadSuccess: (ads: Array) => {
- hilog.info(0x0000, 'testTag', 'Succeeded in loading ad');
- // 期望的底价
- const bidFloor: number = 6;
- const biddingSuccessAds: Array = [];
- for (const ad of ads) {
- const biddingInfo: BiddingInfo = ad.biddingInfo as BiddingInfo;
- if (!biddingInfo) {
- continue;
- }
- if (biddingInfo.cur === 'CNY' && biddingInfo.price >= bidFloor) {
- hilog.info(0x0000, 'testTag', 'Petal Ads wins.');
- if (biddingInfo.nurl) {
- const url: string = biddingInfo.nurl
- // 竞胜时,其他DSP最高出价
- .replace('SECOND_PRICE', '3.6')
- // 价格币种
- .replace('AUCTION_CURRENCY', 'CNY');
- sendBiddingResult(url);
- }
- biddingSuccessAds.push(ad);
- } else {
- hilog.info(0x0000, 'testTag', 'Petal Ads loses.');
- if (biddingInfo.lurl) {
- const url: string = biddingInfo.lurl
- // 竞败时,其他DSP最高出价
- .replace('AUCTION_PRICE', '3.6')
- // 竞价结果
- .replace('AUCTION_LOSS', '102')
- // 价格币种
- .replace('AUCTION_CURRENCY', 'CNY')
- // 竞败时,竞胜DSP推广的App包名
- .replace('AUCTION_APP_PKG', 'com.huawei.music')
- // 竞败时,竞胜DSP推广的App名称
- .replace('AUCTION_APP_NAME', 'music')
- // 竞败时,竞胜DSP的编号
- .replace('AUCTION_CP_ID', '100')
- sendBiddingResult(url);
- }
- }
- }
- // ...此处省略展示广告的逻辑
- }
- };
- async function sendBiddingResult(url: string): Promise<void> {
- let session: rcp.Session | undefined = undefined;
- try {
- session = rcp.createSession();
- await session.get(url);
- } catch (e) {
- hilog.error(0x0000, 'testTag', `Failed to send bidding result. Code is ${e.code}, message is ${e.message}`);
- } finally {
- session?.close();
- }
- }
复制代码 这样,媒体平台就可以实现广告实时竞价的能力了。
当前,实时竞价能力支持的场景有原生广告、激励广告、插屏广告、开屏广告和贴片广告,通过广告实现了从用户唤醒到深度转化的全链路触达。未来,随着隐私计算与AI大模型的深度融合,实时竞价将进一步打破数据孤岛,在保护用户隐私的前提下,让每一次竞价都更具价值,持续引领数字营销向智能化、精细化迈进。
了解更多详情>>
访问广告服务联盟官网
获取实时竞价开发指导文档
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |