2

As I am completely newbie this issue will be probably an easy one for others. My ads are not displayed on the web (various banners, multiple places, none shown). On the www.motoraport.pl/stacje I expect 2 banners to be displayed on the right, but the slots are empty.

When debugging I get an info like

MRPrawa1    
Slot size: 300x250Format: DivService: DFP
Ad unit did not fetch.
Ad unit did not render.
Ad fetch count: 1
Iframe type: none

Warnings:
Ad unit failed to fetch.

-or-

MRPrawa1
Slot size: 300x250Format: DivService: DFP

251 ms to fetch creative
Ad unit did not render.
Ad fetch count: 1
Iframe type: none

However if I click in the debug console Open Creative in New Window I see the banner images. I thought there could have been a code mess up so I created simple localhost page

<!DOCTYPE html>
<html>
    <head>
        <script type='text/javascript'>
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            (function() {
            var gads = document.createElement('script');
            gads.async = true;
            gads.type = 'text/javascript';
            var useSSL = 'https:' == document.location.protocol;
            gads.src = (useSSL ? 'https:' : 'http:') +
            '//www.googletagservices.com/tag/js/gpt.js';
            var node = document.getElementsByTagName('script')[0];
            node.parentNode.insertBefore(gads, node);
            })();

            googletag.cmd.push(function() {
              googletag.defineSlot('/19844765/MRPrawa1', [300, 250], 'div-gpt-ad-1450140062768-3').addService(googletag.pubads());
              googletag.defineSlot('/19844765/MRPrawa2', [300, 250], 'div-gpt-ad-1450140062768-4').addService(googletag.pubads());
              googletag.pubads().enableSingleRequest();
              googletag.pubads().enableSyncRendering();
              googletag.enableServices();
            });
        </script>
    </head>
    <body>
        <!-- MRPrawa1 -->               
        <!-- /19844765/MRPrawa1 -->
        <div id='div-gpt-ad-1450140062768-3' style='height:250px; width:300px;'>
            <script type='text/javascript'>
                googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-3'); });
            </script>
        </div>
        <!-- /19844765/MRPrawa2 -->
        <div id='div-gpt-ad-1450140062768-4' style='height:250px; width:300px;'>
            <script type='text/javascript'>
                googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-4'); });
            </script>
        </div>
    </body>
</html>

But the problem remains. Anybody could help?

Adam Bubela
  • 9,433
  • 4
  • 27
  • 31

1 Answers1

3

After a couple days of pissing in the wind I accidentally discovered that all ad slots that are declared in <head/> must be implemented in <body/>. In my case there were primarily 5 slots declared in head and 1-2 used in body depending on page. Somehow this caused that all ads came up blank. I hope this will help others to get through embedding DFP ads.

Adam Bubela
  • 9,433
  • 4
  • 27
  • 31
  • Huh? I've never known that to be the case. Don't most sites use a consistent header include to initialize every slot, and then alter the delivery on a page by page basis? – Bangkokian Dec 18 '18 at 18:04
  • 1
    I added the main js file to the head, and then moved the slot definitions into the body with the output snippet. That way they only get defined if the output div is there as well. – Robert Went Feb 13 '19 at 19:17