gpt4 book ai didi

google-dfp - 如何使用 googletag.pubads().refresh() 刷新广告?

转载 作者:行者123 更新时间:2023-12-02 06:20:12 25 4
gpt4 key购买 nike

我在页面中有一个广告和一个链接,如下所示:

<!DOCTYPE html>
<head profile="http://www.w3.org/1999/xhtml/vocab">
<title>DPT - Asynchronous + Single Rest Architecture</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.pubads().enableAsyncRendering();
googletag.defineSlot('/1001256/Home_Top_Leaderboard_728x90', [728, 90], 'div-gpt-ad-1342320102476-72').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<div id="div-gpt-ad-1342320102476-72" style="width:728px; height:90px;">
<script type="text/javascript">
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1342320102476-72'); });
</script>
</div>
<a id="refresh" href="#">Refresh ad</a>
<script type='text/javascript'>
(function ($) {
$('#refresh').click(function() {
googletag.cmd.push(googletag.pubads().refresh());
return false;
});
})(jQuery);
</script>
</body>
</html>

我第一次点击链接时,广告会刷新。所有其他时间没有任何反应。即使只是在 Firebug 等中调用 refresh() 方法,在第一次之后也什么都不做。

以上有什么问题?

最佳答案

根据 https://support.google.com/dfp_premium/answer/4578089刷新函数采用广告位数组的参数:

googletag.pubads().refresh([gptAdSlots[0], gptAdSlots[1]]);

这会改变您的行为吗?

否则,我建议通过将 google_consolegoogfc 参数添加到您的查询字符串来启用 Google 发布商控制台(详情请参阅 https://support.google.com/dfp_sb/answer/181070?hl=en),并检查错误

关于google-dfp - 如何使用 googletag.pubads().refresh() 刷新广告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12170327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com