Refresh ads in Google DFP -


having dfp refresh issues when following directions on site.

i've tried other method seen here: refresh dfp ads without luck.

have plugin created stick ad units widgets , works fine. trying update refresh ads , not refresh anything. when try add button refresh ads manually test makes ads disappear completely.

here code that's in 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('/5251611/db_archive_leaderboard_728x90_1', [728, 90], 'div-gpt-ad-1436890018007-0').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_leaderboard_728x90_1', [728, 90], 'div-gpt-ad-1436890018007-1').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_leaderboard_728x90_2', [728, 90], 'div-gpt-ad-1436890018007-2').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_1', [300, 250], 'div-gpt-ad-1436890018007-3').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_2', [300, 250], 'div-gpt-ad-1436890018007-4').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_3', [300, 250], 'div-gpt-ad-1436890018007-5').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_4', [300, 250], 'div-gpt-ad-1436890018007-6').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_5', [300, 250], 'div-gpt-ad-1436890018007-7').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_med_rect_300x250_6', [300, 250], 'div-gpt-ad-1436890018007-8').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_frontpage_pencil_975x50', [975, 50], 'div-gpt-ad-1436890018007-9').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_half_page_300x600', [300, 600], 'div-gpt-ad-1436890018007-10').addservice(googletag.pubads());     googletag.defineslot('/5251611/db_posts_leaderboard_728x90_1', [728, 90], 'div-gpt-ad-1436890018007-11').addservice(googletag.pubads());     googletag.pubads().enablesinglerequest();     googletag.enableservices();   }); </script> 

and sample of ad plugin code :

 <!-- /5251611/db_half_page_300x600 -->     <div id='div-gpt-ad-1436890018007-10' style='height:600px; width:300px; padding:10px 0px 10px 10px;'>  <script type="text/javascript">           googletag.cmd.push(function() {         var slot10 = googletag.defineslot("/5251611/db_half_page_300x600", [300, 600],         "div-gpt-ad-1436890018007-10").addservice(googletag.pubads());         googletag.enableservices();         googletag.display("div-gpt-ad-1436890018007-10");     setinterval(function(){googletag.pubads().refresh([slot10]);}, 30000);                });       </script>  </div> 

the ad code above same 10 ad slots slot number changed in each one. missing here? cannot refresh after 30 seconds.

console right. setinterval function not recognize slot10 because out of scope. if write following: googletag.pubads().refresh([slot10]) rather using in setinterval function see ad refreshed.

you should make code setinterval can access slot10. maybe should pass slot10 variable setinterval function??


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -