Google Publisher Tag in an array

477 views Asked by At

I have successfully implemented this kind of Google Publisher Tags code before, but now I cannot get ads to appear. The documentation shows no examples of GPT in an array, so I'm not sure what to do.

I used a third party to generate publisher tags, as Google itself now makes you create a publisher tag each time for every ad.

Here is my tag code:

   <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>
0

There are 0 answers