Placeholder
Placeholder

Reputation: 689

Google ads are not refreshing

So I am using the default system that google provides for refreshing your ads every 30 seconds on my ajax themed website. The ads go through when I am using adblock I can see the ad count updating on the page so it's refreshing them but they don't display at all on the page for some reason.

<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("/6931143405/Sound", [728, 90], "leaderboard").
 setTargeting("Sound", "refresh").
 addService(googletag.pubads());

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

// Set timer to refresh slot every 10 seconds
setInterval(function(){googletag.pubads().refresh([slot1]);}, 10000);
});
</script>

With the javascript above I am almost certain that with the div below it should refresh the ad or at least display the ad in the div.

<center><div id="leaderboard" style="width:728px; height:90px;"></div></center>

Where it says

defineSlot("/XXXX/sound"

the XXXX should be changed to

data-ad-slot="XXXX"

This line in google adsenses default code correct?

Upvotes: 0

Views: 481

Answers (1)

Richard Dillman
Richard Dillman

Reputation: 334

I see nothing wrong with your code, and the ad is calling and refreshing, but the url being called is failing (404). Are you sure your network ID is correct? Possibly this tag combo is rate limited?

http://pubads.g.doubleclick.net/gampad/ads?gdfp_req=1&correlator=2597499592245248&output=json_html&callback=callbackProxy&impl=fif&fif_to=1&sfv=1-0-2&iu=%2F6931143405%2FSound&sz=728x90&scp=Sound%3Drefresh&eri=1&cookie_enabled=1&lmt=1426955251&dt=1426955251200&cc=100&frm=20&biw=1869&bih=495&oid=3&adx=496&ady=1254&adk=1526223150&gut=v2&ifi=37&u_tz=-240&u_his=9&u_java=true&u_h=1080&u_w=1920&u_ah=1050&u_aw=1920&u_cd=24&u_nplug=10&u_nmime=52&u_sd=1&flash=17.0.0&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F27495188%2Fgoogle-ads-are-not-refreshing&ref=http%3A%2F%2Fstackoverflow.com%2Fsearch%3Ftab%3Dnewest%26q%3D%255bjavascript%255d%2520googletag&vrg=58&vrp=58&ga_vid=953776431.1420416155&ga_sid=1426954906&ga_hid=728666356

Upvotes: 1

Related Questions