Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use multiple adsense units on one page?

Tags:

adsense

How do you have multiple adsense units on one website? The only code Google gives are per unit.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"      style="display:inline-block;width:300px;height:250px"      data-ad-client="ca-pub-123456"      data-ad-slot="123456"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> 

What if I want to use multiple adsense units on one website? I only use <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> and (adsbygoogle = window.adsbygoogle || []).push({}); once, and then place the <ins ...></ins> code where I want it to be.

The problem is that only the first adsense unit is parsed and shown. What do you need to do to be able to display more than one adsense unit?

This is how I use it (only first ins is shown):

<!doctype html> <html>     <body>         <ins class="adsbygoogle"          style="display:inline-block;width:300px;height:250px"          data-ad-client="ca-pub-123456"          data-ad-slot="first"></ins>           <ins class="adsbygoogle"          style="display:inline-block;width:300px;height:250px"          data-ad-client="ca-pub-123456"          data-ad-slot="second"></ins>           <ins class="adsbygoogle"          style="display:inline-block;width:300px;height:250px"          data-ad-client="ca-pub-123456"          data-ad-slot="third"></ins>          <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>         <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>     </body> </html> 
like image 673
Marwelln Avatar asked Aug 02 '14 14:08

Marwelln


People also ask

Can we apply multiple AdSense on one website?

AdSense policies only allow one account per publisher. We've provided some guidance below that may help you if you're trying to submit multiple applications to resolve an issue.

How many AdSense ads can you have per page?

Currently, AdSense publishers may place up to three AdSense for content units on one webpage. This includes a maximum of one 300x600 ad unit per page. You may also place a maximum of three link units and two search boxes on each webpage.

How many AdSense ads can you have per page 2021?

Publishers used to be able to have only 3 ads per page. Now, they can have unlimited AdSense ads on a single page. However, the total number of AdSense ads or third-party ads (such as text, image, rich media, click to download, video, native, and other formats) must not exceed the content.

How do I add multiple websites to AdSense?

Click Add site. Enter the URL of your site. Note: If your site is on one of our host partner sites (like Blogger or YouTube, among many others), you'll need to go to your host partner to add your site to AdSense. Click Save and continue.


1 Answers

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({}); }); 
like image 129
Marwelln Avatar answered Nov 30 '22 08:11

Marwelln