我们只有一个广告标签从我们的广告合作伙伴。在同一个页面上,我们希望使用相同的广告单元提供多个广告。我们使用广告标签来实现这个正式的Google文档:https://developers.google.com/publisher-tag/samples/infinite-content。不过,只有第一条广告才能送达。当我们生成更多的广告时,每个新标签上都会形成一个google-query-id,但是没有真正显示广告。我们是否犯了任何错误,在广告合作伙伴方面有什么需要设置的呢?
代码:
<html>
<head>
<title>Infinite content example</title>
<script
async
src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"
></script>
<script>
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(function () {
googletag
.defineSlot(
"/XXXXXX/XXXXXX",
[
[300, 100],
[200, 200],
[300, 300],
[200, 250],
[250, 250],
[300, 250],
[750, 200],
[970, 250],
],
"div-gpt-ad-some-id"
)
.setTargeting("test", "infinitescroll")
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
// Function to add content to page
function moreContent() {
// Define the slot itself, register it and fetch an ad.
googletag.cmd.push(function () {
var slot = googletag
.defineSlot("/XXXXXX/XXXXXX", [
[300, 100],
[200, 200],
[300, 300],
[200, 250],
[250, 250],
[300, 250],
[750, 200],
[970, 250],
])
.setTargeting("test", "infinitescroll")
.addService(googletag.pubads());
var div = document.createElement("div");
div.id = slot.getSlotElementId(); // auto-generated by GPT
document.body.appendChild(div);
// Call display() to register the slot as ready and fetch an ad.
googletag.display(slot);
});
}
</script>
<style>
body > div {
margin-bottom: 5em;
border: solid 1px black;
width: 728px;
}
body > button {
position: fixed;
bottom: 40%;
}
</style>
</head>
<body>
<h1>GPT Test Page - Infinite Content</h1>
<!-- First ad -->
<div id="div-gpt-ad-some-id">
<script>
// Call display() to register the slot as ready and fetch an ad.
googletag.cmd.push(function () {
googletag.display("div-gpt-ad-some-id");
});
</script>
</div>
<!-- Button to load more content dynamically. -->
<button onclick="moreContent()">More Content</button>
</body>
</html>发布于 2022-11-23 08:06:36
我上面的代码是正确的。但是为了提供相同的标签多个广告,你需要在谷歌广告经理中设置相应数量的创意广告。也就是说,如果你想使用相同的标签5次,你需要有5名创意人员在谷歌广告经理。在我的例子中,提供的gpt标记在GAM上只有一个创造性的设置。这就是为什么只有一个标签充满了广告。
https://stackoverflow.com/questions/74124353
复制相似问题