Google even does this, however I do not understand the part of googletag.DefineSlots, I do not know where it gets that numbering. Google Example:
<script>
// Load GPT asynchronously
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>
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>