【问题标题】:Google DFP Ad show for click events针对点击事件的 Google DFP 广告展示
【发布时间】:2017-09-25 08:17:59
【问题描述】:

我想在用户点击 navbar 时显示 google dfp 单元

$(document).ready(function () {
  var navbar = false;
  var navslot = null;
  $(document).on('click', '.new_car_nav', function(){
    navslot = googletag.defineSlot('/10176910/NavBar', [[250, 250]], 'ad_navbar').addService(googletag.pubads());
    googletag.enableServices();
    googletag.display('ad_navbar');
  });
});

问题是它给出了错误

Exception in queued GPT command TypeError: $ is not defined

我们是否可以在其中使用 jquery?如果没有,那我该如何实现呢?

【问题讨论】:

    标签: javascript jquery google-analytics google-dfp gpt


    【解决方案1】:

    您需要包含 jQuery,将其添加到您的 <head>

    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
    

    【讨论】:

      【解决方案2】:

      您缺少jQuery 库,您需要在任何其他库包含之前将其包含到head section

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      

      希望这会对你有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-28
        • 1970-01-01
        • 1970-01-01
        • 2017-02-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多