I use DoubleClick For Publishers (DFP) ads. This is the page: http://www.ifly.com
I load DFP ads via jQuery AJAX after the page load event to make my various search widgets available to user interaction as quickly as possible. The process looks something like this.
Place the initial DFP header calls in the document header.
<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); })(); </script> <script type='text/javascript'> googletag.cmd.push(function() { googletag.defineSlot('/9358962/HP-300x250', [300, 250], 'div-gpt-ad-1353002461867-0').addService(googletag.pubads()); googletag.defineSlot('/9358962/HP-460x60', [468, 60], 'div-gpt-ad-1353002461867-1').addService(googletag.pubads()); googletag.defineSlot('/9358962/HP-728x90', [728, 90], 'div-gpt-ad-1353002461867-2').addService(googletag.pubads()); googletag.defineSlot('/9358962/HP-LAF-160x600', [160, 600], 'div-gpt-ad-1353002461867-3').addService(googletag.pubads()); googletag.defineSlot('/9358962/HP-RAF-160x600', [160, 600], 'div-gpt-ad-1353002461867-4').addService(googletag.pubads()); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script> .... </head>
Create an empty div as a placeholder.
<div id='horizontalTANBanner'></div>
After the page loads, paste the code using jQuery AJAX to retrieve the ad.
<div id='horizontalTANBanner'> <div id='div-gpt-ad-1353002461867-2' style='width:728px; height:90px;'> <script type='text/javascript'> googletag.cmd.push(function() { googletag.display('div-gpt-ad-1353002461867-2'); }); </script> </div> </div>
Google loads even more JavaScript to actually call the ad. I see that it was inserted using Firebug.
<div id="horizontalTANBanner"> <div id="div-gpt-ad-1353002461867-2" style="width:728px; height:90px;"> <iframe id="google_ads_iframe_/9358962/HP-728x90_0" width="728" scrolling="no" height="90" frameborder="0" name="google_ads_iframe_/9358962/HP-728x90_0" marginwidth="0" marginheight="0" style="border: 0px none;"> <html> </iframe> <iframe id="google_ads_iframe_/9358962/HP-728x90_0__hidden__" width="0" scrolling="no" height="0" frameborder="0" name="google_ads_iframe_/9358962/HP-728x90_0__hidden__" marginwidth="0" marginheight="0" style="border: 0px none; visibility: hidden; display: none;"> </div> </div>
I see that ads are displayed in every browser, but Firefox (IE, Chrome, Opera, Safari). I have confirmed to other users that they cannot see ads in Firefox. How to show ads in Firefox?
I asked this question in the DFP forum, but they are not technical and their best answer was βStop using AJAX,β but the experience of visitors is much better, and I expect Google to rank my pages better than not to load slowly, so I hate stop using it.