On my site, the AdSense content is loaded dynamically via javascript. The article content is retrieved via AJAX then displayed on the page. When it is displayed, the AdSense code is appended to the article.
You can see it in action at: http://thepresslist.com.au/
The code should appear just above where you can see the word 'Advert'. On my end, I can only see a blank area where the ad should appear, but no ad. Looking at the source of the final page, the code appears to be correct. AdBlock is disabled and Javascript is on. I see no obvious errors in my AdSense account.
Is anyone able to shed some light onto why no ads are displayed?
This is the code that generates the ad placement (the array is the Google AdSense script, exploded, to split up the </script>
tags.
articleAd.innerHTML = <?php
$numItems = count($site_content_adverts);
$i = 0;
foreach ($site_content_adverts as &$value) {
if(++$i === $numItems) {
echo '"' . $value . '" + ';
} else {
echo '"' . $value . '" + "pt>" + ';
}
}
?> "Advert";
On the loaded page, the above script looks like this (after the exploded string is echoed):
articleAd.innerHTML = "<style>.press-list-ad-1 { width: 320px; height: 50px; }@media(min-width: 500px) { .press-list-ad-1 { width: 468px; height: 60px; } }@media(min-width: 800px) { .press-list-ad-1 { width: 728px; height: 90px; } }</style><script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></scri" + "pt>" + "<!-- Press List Ad 1 --><ins class=\"adsbygoogle press-list-ad-1\" style=\"display:inline-block\" data-ad-client=\"ca-pub-1801533XXXXXXXX06\" data-ad-slot=\"68XXXXXXXXX105\"></ins><scri" + "pt>" + "(adsbygoogle = window.adsbygoogle || []).push({});</scri" + "pt>" + "" + "Advert";
This is the code that is rendered each time a new article loads:
<style>.press-list-ad-1 { width: 320px; height: 50px; }@media(min-width: 500px) { .press-list-ad-1 { width: 468px; height: 60px; } }@media(min-width: 800px) { .press-list-ad-1 { width: 728px; height: 90px; } }</style>
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Press List Ad 1 -->
<ins class="adsbygoogle press-list-ad-1" style="display:inline-block" data-ad-client="ca-pub-1801XXXXX58006" data-ad-slot="6898XXXXXXX05"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>