首页 > 解决方案 > 未在 YouTube 上展示的广告嵌入 iframe

问题描述

我已经使用 js 来包含 iframe youtube embed

<html>
  <body>
    <div id="video"></div>
  </body>

  <script>
    // JS
    var tag = document.createElement("script");
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName("script")[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

    function onYouTubeIframeAPIReady() {
      video = new YT.Player("video", {
        height: 360,
        width: 640,
        videoId: "rfYydagxcJI",
        host: "https://www.youtube.com",
        playerVars: {
          fs: 0,
          modestbranding: 1,
          playsinline: 1,
          rel: 0,
        },
      });
    }
  </script>
</html>

我也尝试添加

<iframe width="560" height="315" src="https://www.youtube.com/embed/goSiidPyiYA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

但这两者都没有按照 YouTube 显示任何来自 YouTube 的广告。

标签: iframeyoutubeyoutube-apiyoutube-data-apiadsense

解决方案


如果嵌入式网站不值得信赖,Google 可能不会显示广告,以下信息来自 Google。

嵌入式视频上的广告要求

广告出现在品牌安全网站上:YouTube 努力工作,以便我们广告客户的品牌出现在反映我们各自核心价值观的网站上。在确定是否在 YouTube 嵌入中启用视频插播广告时,我们的系统会根据各种因素仔细评估网站及其内容。这些因素包括一套严格的关于成人图像、暴力、不当和仇恨语言以及宣传侵权的网站等内容的指导方针。

播放器详细信息:我们要求视频播放器看起来足够大,以促进积极的用户体验。我们建议使用 560x315 像素或更大的播放器。此外,视频应该使用标准的点击播放嵌入而不是脚本播放来嵌入

来源:https ://support.google.com/youtube/answer/132596?hl=en


推荐阅读