0

setinterval DFP

Craig V 4 years ago in BLOX CMS 0

I need to be able to refresh ads on our site. We use DFP and in Flex I am unable to add the var slot1. how do I add: var slot1 in flex?
Sample code:

 <script>

   googletag.cmd.push(function() {

    // Define the ad slot
    var slot1 = googletag.defineSlot("/6355419/Travel", [728, 90], "leaderboard").
     setTargeting("test", "refresh").
     addService(googletag.pubads());

   // Start ad fetching
   googletag.enableServices();
   googletag.display("leaderboard");

   // Set timer to refresh slot every 30 seconds
   setInterval(function(){googletag.pubads().refresh([slot1]);}, 30000);
   });

 </script>