在Meteor框架中添加Google双击广告

时间:2015-05-19 10:23:55

标签: javascript meteor adsense google-dfp double-click-advertising

我尝试使用https://gentlenode.com/journal/meteor-18-add-google-adsense-to-your-application/37中的相同代码,这适用于AdSense,但它无法使用Google DFP代码。 Google js不会触发标记内的任何代码。

Template.sidebar.rendered = function() {
  $.getScript("//www.googletagservices.com/tag/js/gpt.js", function() {
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];

  googletag.cmd.push(function() {
  googletag.defineSlot('/58419895/sidebar_large', [300, 600], 'div-gpt-ad-1432029985552-0').addService(googletag.pubads());
  googletag.pubads().enableSingleRequest();
  googletag.enableServices();
 });

 var ads = "<div id='div-gpt-ad-1432029985552-0' style='height:600px; width:300px;'>";
 $("#square-long").html(ads);  
 return googletag.cmd.push(function() { googletag.display('div-gpt-ad-1432029985552-0'); });
 });

};

0 个答案:

没有答案