This passage compiles the procedures to use adsense and some major problems like "avaliable width = 0" problem that people face when using adsense.

1. Why you should use adsense

Reasons to use adsense from google

2. Preparation

  • A blog with some original articles
  • A Google account

3. Application

[1]

  1. Apply for adsense - Click
  2. Put the script in head label in your website
  3. Waiting for verification - will last about 2 and 3 days

4. Configuraiton

There are three different types of ads in google adsense:

  • Auto ads
  • In-feed ads
  • In-article ads
  1. Auto ads

Auto ads is put in your website by using machine learning techniques from google. You can also customize the settings to determine whether to show an ad in a certain places.

  1. In-feed ads

From its name, we can know that its for websites that has feed(usually this type of ad is put at the home page). You can determine which place to put this ad, and you can also determine how many ads do you want to place in your feed. If you are using gridea, you can look for the following code to add In-feed ads in your feed page:

<% if (seq % 3 == 0) {%> <ins class="adsbygoogle" //seq is from <% posts.forEach(function(post, seq) { %>
     style="display:block"
     data-ad-format="fluid"
     data-ad-layout-key="your key"
     data-ad-client="your ad-client"
     data-ad-slot="your ad-slot"></ins><script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script> <%} %>
  1. In-article ads

This type of ad is used in article. The formal suggestion is to put this ad at the end of the second paragraph of the article. This ad can automatically detect your content and put suitable ads in your article.


Besides these ads, you can also choose the type of ads you want to show in your website and manually censor all the ads that has appeared in your site.

The place to censor all the ads

In this place, you can approve or block ads.

However, this procedure may take you a lot of time. Thus, you can go to the Content ads to determine whether you want certain type of ads shown in your website(Like the ads about sex).

If you do not screen some ads, these ads may be shown in your website:
Some "dirty" ads in appinn from adsense

5. Problems

But you will face some problems when using adsense.

  • Fluid responsive ads must be at least 250px wide
Avaliable width is zero

There are two ways to solve this problem:

  1. If you are using Jquery, you can use the following code[2]
<script>
/* Warning: this is non-recommended code */
  jQuery(document).ready(function () {
    (adsbygoogle = window.adsbygoogle || []).push({});
  });
</script>
  1. I discover another solution to solve this problem:

Put the following css code in your css file:

ins{
    width:100% !important;
    display:block !important;
}
//Replace this code with the new one
(adsbygoogle = window.adsbygoogle || []).push({});

//new
window.onload = function() {
    (adsbygoogle = window.adsbygoogle || []).push({});
}

This can solve the problem, but sometimes it doesn't work either. But most of time, it can ensure that ads can be shown in your website.

6. Ending

Please notice: you can withdraw only when you earn greater than or equal 100$ in adsense.


  1. From Yiyun's Blog↩︎

  2. Solve the avaliable width problem from galeksic↩︎