首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无限滚动-不能使用相同的广告单元在同一个页面上提供多个广告。

无限滚动-不能使用相同的广告单元在同一个页面上提供多个广告。
EN

Stack Overflow用户
提问于 2022-10-19 11:12:05
回答 1查看 60关注 0票数 2

我们只有一个广告标签从我们的广告合作伙伴。在同一个页面上,我们希望使用相同的广告单元提供多个广告。我们使用广告标签来实现这个正式的Google文档:https://developers.google.com/publisher-tag/samples/infinite-content。不过,只有第一条广告才能送达。当我们生成更多的广告时,每个新标签上都会形成一个google-query-id,但是没有真正显示广告。我们是否犯了任何错误,在广告合作伙伴方面有什么需要设置的呢?

代码:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2022-11-23 08:06:36

我上面的代码是正确的。但是为了提供相同的标签多个广告,你需要在谷歌广告经理中设置相应数量的创意广告。也就是说,如果你想使用相同的标签5次,你需要有5名创意人员在谷歌广告经理。在我的例子中,提供的gpt标记在GAM上只有一个创造性的设置。这就是为什么只有一个标签充满了广告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74124353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档