I'm trying to get some Google Ads to play nice. Basically, we have some inline ads that we display between listings:
<div class="listing-ad" id="ad<%row_num%>">
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1210636681400112"
data-ad-slot="2068176827"
data-ad-format="horizontal"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
These work ok. We load the Google scripts in requireJS using:
"google_ads": "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1210636681400112",
We now want to include an "anchor" ad at the bottom of the page. As per the article ( https://support.google.com/adsense/answer/7478225?hl=en ), I'm adding this near the end of my page:
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-1210636681400112",
enable_page_level_ads: true,
overlays: {bottom: true}
});
When running their example, the ad shows but I get:
{ message: "adsbygoogle.push() error: Only one 'enable_page_level_ads' allowed per page.",
If I comment out enable_page_level_ads: true,
the ad still shows (but not at the bottom), and I then get a new error message:
message: "adsbygoogle.push() error: All ins elements in the DOM with class=adsbygoogle already have ads in them.",
I'm at my witts end as to what else to try. I guess ideally, I'd like an <ins>
HTML option where I can pass data-ad-overlays="bottom" as an option (vs doing it as a <script>
).
I've even tried passing the options via:
(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-1210636681400112", enable_page_level_ads: true, overlays: { bottom: true } })
Yet still no joy.
Is this possible? Am I missing something stupid? I feel like I've been chasing my tail on this for hours now!
Bottom anchor ads aren't well supported today. There is no good way to force them as top anchors are default and AdSense frontend doesn't provide way to switch to bottom. The article you provided is outdated and needs to be revamped or more likely removed. But if you do want to force bottom anchors you can try the following snippet:
<head>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-1234567891234567",
enable_page_level_ads: true,
overlays: {bottom: true}
});
</script>
</head>
Note that web property id is no longer present in the tag and that makes the difference. Though by removing web property id you might miss on some other optimizations.