Search code examples
javascriptgoogle-publisher-tag

Google ad dfp js code is not rendering all ad slots


I would like some help to set up my google dfp code better.

I have already tried to set the slots individually but it is not rendering all the ad slots.

this is the add code slote definitions:

<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
</script>
<script type="text/javascript">
  googletag.cmd.push(function() {
    googletag.defineSlot('#########/accessnepa', [[300,600]], 'div-gpt-ad-ROS')
             .setTargeting('position', ['ATF'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-EatDrink-1')
              .setTargeting('position', ['BTF'])
              .setTargeting('Category', ['EatDrink'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-EatDrink-2')
             .setTargeting('position', ['BTF2'])
             .setTargeting('Category', ['EatDrink'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-ChefTable')
             .setTargeting('position', ['ATF'])
             .setTargeting('setTargeting', ['Category', 'ChefTable'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-LocalFlavor')
             .setTargeting('position', ['ATF'])
             .setTargeting('setTargeting', ['Category', 'LocalFlavor'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-EmptyBottles')
             .setTargeting('position', ['ATF'])
             .setTargeting('setTargeting', ['Category', 'EmptyBottles'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Liquid')
             .setTargeting('position', ['ATF'])
             .setTargeting('setTargeting', ['Category', 'Liquid'])
             .addService(googletag.pubads());

    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-HealthBeauty')
               .setTargeting('position', ['ATF'])
               .setTargeting('Category', ['HealthBeauty'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-HealthBeauty-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['HealthBeauty'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-HeyBeautiful')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['HeyBeautiful'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-LiveFit')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['LiveFit'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-ScreenTime')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['ScreenTime'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-ScreenTime-2')
             .setTargeting('position', ['BTF2'])
             .setTargeting('Category', ['ScreenTime'])
             .addService(googletag.pubads());

    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Take2')
             .setTargeting('position', ['ATF'])
             .setTargeting('setTargeting', ['Category', 'Take2'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-HistoricallyHip')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['HistoricallyHip'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-HistoricallyHip-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['HistoricallyHip'])
             .addService(googletag.pubads());
       googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-SportsOutdoors')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['SportsOutdoors'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-SportsOutdoors-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['SportsOutdoors'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-PagesFromThePast')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['PagesFromThePast'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-CausesBenefits')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['CausesBenefits'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-CausesBenefits-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['CausesBenefits'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-InTimesOfNeed')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['InTimesOfNeed'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-TalkOfTheTimes')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['TalkOfTheTimes'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-UpClose')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['UpClose'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-UpClose-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category', ['UpClose'])
             .addService(googletag.pubads());

    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-TrailMix')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['TrailMix'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-PennState')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['PennState'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Railriders')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['RailRiders'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-HSSports')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['HSSports'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Multimedia')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['Multimedia'])

.addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Multmedia-2')
             .setTargeting('position', ['BTF'])
             .setTargeting('Category'['Multimedia'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-Podcasts')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['Podcasts'])
             .addService(googletag.pubads());
    googletag.defineSlot('#########/accessnepa', [[300,250]], 'div-gpt-ad-PhotoBlog')
             .setTargeting('position', ['ATF'])
             .setTargeting('Category', ['PhotoBlog'])
             .addService(googletag.pubads());

      googletag.pubads().enableSingleRequest();
    //  googletag.pubads().setTargeting("Category",['EatDrink'], ['ROS'], ['ChefTable'], ['LocalFlavor'], ['EmptyBottles'], ['Liquid'], ['HealthBeauty'], ['HeyBeautiful'], ['LiveFit'], ['ScreenTime'], ['Take2'], ['HistoricallyHip'], ['PagesFromThePast'], 
  // ['CausesBenefits'], ['InTimesOfNeed'], ['TalkOfTheTimes'], ['UpClose'], ['SportsOutdoors'], ['TrailMix'], ['PennState'], 
  // ['RailRiders'], ['HSSports'], ['Multimedia'], ['Podcasts'], ['PhotoBlog']);
googletag.enableServices();
  });
</script>

i need help defining all the slots


Solution

  • It might be that you don't have enough creatives.

    EXAMPLE: Imagine that your DFP has three 300x250 ad units and 1 line item, targeting all three of them.

    • If the line item only has one creative, then only one ad unit will render it (the one which is defined first).
    • If the line item has two creatives, then only one ad unit will be blank.
    • If you add a third creative, then all three will show an ad.