【发布时间】:2018-06-04 09:24:13
【问题描述】:
我也想这样做,但使用 GPT APi(我对这种编码东西很陌生,所以不知道在做什么,所以寻求帮助)
我在 GPT ApI 文档中找到了这个:
-
展示可视化监听器,特定于广告位的逻辑。 当印象被视为可见时,将调用侦听器。 此事件也在服务级别运行,但如上所述,您可以过滤 使用此模式仅响应某个广告位
googletag.pubads().addEventListener('impressionViewable', function(event) { if (event.slot == targetSlot) { //插槽特定逻辑。 } });
并且已经有了这个,它会在 X 秒后刷新广告
googletag.cmd.push(function() {
var mappingleaderslot = googletag.sizeMapping().
addSize([1024, 769], [[970,250],[970,90],[728,90],[468,60],[320,50],[234,60]]).
addSize([768, 500], [[728,90],[468,60],[320,50],[234,60]]).
addSize([1, 1], [[320,50],[234,60]]).
build();
var mappingbigboxslot = googletag.sizeMapping().
addSize([1024, 769], [[300,600],[300,250],[160,600],[120,600],[250,250]]).
addSize([768, 500], [[300,250],[250,250]]).
addSize([1, 1], [[300,250],[250,250]]).
build();
topSlot = googletag.defineSlot('/1001824/prebid_test2', [[970, 250],[970, 90],[728, 90],[468, 60],[320, 50],[234, 60]], 'topSlot').defineSizeMapping(mappingleaderslot).setTargeting("test", "refresh").addService(googletag.pubads());
middlerightSlot = googletag.defineSlot('/1001824/prebid_test3', [[300, 600],[300, 250],[160, 600],[120, 600],[250, 250]], 'middlerightSlot').defineSizeMapping(mappingbigboxslot).setTargeting("test", "refresh").addService(googletag.pubads());
bottomrightSlot = googletag.defineSlot('/1001824/prebid_test1', [[300, 600],[300, 250],[160, 600],[120, 600],[250, 250]], 'bottomrightSlot').defineSizeMapping(mappingbigboxslot).setTargeting("test", "refresh").addService(googletag.pubads());
bottomleftSlot = googletag.defineSlot('/1001824/prebid_test4', [[300, 600],[300, 250],[160, 600],[120, 600],[250,250]], 'bottomleftSlot').defineSizeMapping(mappingbigboxslot).setTargeting("test", "refresh").addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs(true, true);
googletag.pubads().setCentering(true);
googletag.enableServices();
googletag.display("topSlot");
googletag.display("middlerightSlot");
googletag.display("bottomrightSlot");
googletag.display("bottomleftSlot");
setInterval(function(){googletag.pubads().refresh([topSlot]);}, 120000);
setInterval(function(){googletag.pubads().refresh([middlerightSlot]);}, 120000);
setInterval(function(){googletag.pubads().refresh([bottomrightSlot]);}, 120000);
setInterval(function(){googletag.pubads().refresh([bottomleftSlot]);}, 120000);
});
function refreshSlot(slot) {
pbjs.que.push(function() {
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
adUnitCodes: [slot.getSlotElementId()],
bidsBackHandler: function() {
pbjs.setTargetingForGPTAsync([slot.getSlotElementId()]);
googletag.pubads().refresh([slot]);
}
});
});
}
function refreshtopSlot() {
refreshSlot(topSlot);
}
function refreshmiddlerightSlot() {
refreshSlot(middlerightSlot);
}
function refreshbottomrightSlot() {
refreshSlot(bottomrightSlot);
}
function refreshbottomleftSlot() {
refreshSlot(bottomleftSlot);
}
但我不知道如何将两者结合起来,因此当广告在“可见”X 秒后刷新时,任何指针/任何人都可以帮助我吗?
【问题讨论】:
标签: google-dfp