How do you use multiple adsense units on one page?

Using jQuery...

$(".adsbygoogle").each(function () { (adsbygoogle = window.adsbygoogle || []).push({}); });

To have more then one adsense unit on one page you must add more rows of (adsbygoogle = window.adsbygoogle || []).push({});.

So if you have 3 ad units, you want to use it 3 times.

(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});

If you want to do it dynamically, use this:

[].forEach.call(document.querySelectorAll('.adsbygoogle'), function(){
    (adsbygoogle = window.adsbygoogle || []).push({});
});

Tags:

Adsense