Error showing ads from Google Adsense


#1

I have a problem using Google Adsense. In my meteor app I have several pages, using iron router. On each page I have included a template called ‘ads’. When navigating through the pages on the first 5 pages the ads are shown well. But always on exact the 6th page I get an error 400 on show_ads_impl.js:490.

I did already try to place the Google Adsense code into an iframe, but that doesn’t work well either. That also gave me troubles with the responsive ad format.

Does anyone implemented Google Adsense succesfully in a meteor app?

Here is my code:

ads.html:

<template name="ads">
   <div class="ads"></div>
</template>

ads.js:

Template.ads.onRendered(function() {
  $.getScript("//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", function() {
    var ads, adsbygoogle;
    ads = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-XXXXX" data-ad-slot="XXXXXX" data-ad-format="auto"></ins>';
    $('.ads').html(ads);
    return (adsbygoogle = window.adsbygoogle || []).push({});
  });
});