0

我之前已经成功实现了这种 Google Publisher Tags 代码,但现在我无法让广告出现。该文档未显示数组中的 GPT 示例,因此我不确定该怎么做。

我使用第三方来生成发布商标签,因为 Google 本身现在让您每次为每个广告都创建一个发布商标签。

这是我的标签代码:

   <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
    
<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
</script>

<script>
var gptAdSlots = [];
  googletag.cmd.push(function() {

//blog
  var BlogAdSpace3Map = googletag.sizeMapping().
  addSize([992, 0], [728,90]).//desktop
  addSize([768, 0], [468,60]). //tablet
  addSize([200, 0], [320, 50]). //phone
  build();
//momentum
  var MOMAdSpace1Map = googletag.sizeMapping().
  addSize([992, 0], [970,250]).//desktop
  addSize([768, 0], [728,90]). //tablet
  addSize([200, 0], [320,100]). //phone
  build();

var MOMAdSpace3Map = googletag.sizeMapping().
  addSize([992, 0], [728,90]).//desktop
  addSize([768, 0], [468,60]). //tablet
  addSize([200, 0], [320, 50]). //phone
  build();

  var MOMAdSpace4Map = googletag.sizeMapping().
  addSize([992, 0], [728,90]).//desktop
  addSize([768, 0], [468,60]). //tablet
  addSize([200, 0], [320, 50]). //phone
  build();

  var MOMAdSpace6Map = googletag.sizeMapping().
  addSize([992, 0], [[468,60]).//desktop and tablet
  addSize([200, 0], [320,50]). //phone
  build();

//blog ad spots  
gptAdSlots[0] =  googletag.defineSlot('/27450918/BLOG_AdSpace2_SB_T_Square', [[300,250]], 'div-gpt-ad-8571790-1')            
             .addService(googletag.pubads());
             
gptAdSlots[1] =  googletag.defineSlot('/27450918/BLOG_AdSpace3_MC_B_Leaderboard', [[728,90],[468,60],[320,50]], 'div-gpt-ad-8571790-2').defineSizeMapping(BlogAdSpace3Map).addService(googletag.pubads());

gptAdSlots[2] =  googletag.defineSlot('/27450918/BLOG_AdSpace5_SB_M_WideSkyScraper', [[300,600]], 'div-gpt-ad-8571790-3').addService(googletag.pubads());

gptAdSlots[3] =  googletag.defineSlot('/27450918/BLOG_AdSpace7_SB_B_Square', [[300,250]], 'div-gpt-ad-8571790-4').addService(googletag.pubads());

gptAdSlots[4] =  googletag.defineSlot('/94124639/Ad_Space_E_Half_Page_Sidebar_Live', [300, 600], 'div-gpt-ad-1492297948399-4').addService(googletag.pubads());

//momentum ad spots

gptAdSlots[5] = googletag.defineSlot('/27450918/MOM_AdSpace1_MC_T_LargeBillboard', [[970,250],[728,90],[320,100]], 'div-gpt-ad-7254248-1').defineSizeMapping(MOMAdSpace1Map).addService(googletag.pubads());

gptAdSlots[6] = googletag.defineSlot('/27450918/MOM_AdSpace2_SB_T_Square', [[300,250]], 'div-gpt-ad-7254248-2').addService(googletag.pubads());

gptAdSlots[7] = googletag.defineSlot('/27450918/MOM_AdSpace3_MC_B_Leaderboard', [[728,90],[468,60],[320,50]], 'div-gpt-ad-7254248-3').defineSizeMapping(MOMAdSpace3Map).addService(googletag.pubads());

gptAdSlots[8] = googletag.defineSlot('/27450918/MOM_AdSpace4_MC_MT_Leaderboard', [[728,90],[468,60],[320,50]], 'div-gpt-ad-7254248-4').defineSizeMapping(MOMAdSpace4Map).addService(googletag.pubads());

gptAdSlots[9] = googletag.defineSlot('/27450918/MOM_AdSpace5_SB_M_WideSkyScraper', [[300,600]], 'div-gpt-ad-7254248-5').addService(googletag.pubads());

gptAdSlots[10] = googletag.defineSlot('/27450918/MOM_AdSpace6_MC_MB_StandardBanner', [[468,60],[320,50]], 'div-gpt-ad-7254248-6').defineSizeMapping(MOMAdSpace6Map).addService(googletag.pubads());

gptAdSlots[11] = googletag.defineSlot('/27450918/MOM_AdSpace7_SB_B_Square', [[300,250]], 'div-gpt-ad-7254248-7').addService(googletag.pubads());


googletag.pubads();

googletag.enableServices();


 });

    </script>
4

0 回答 0