How to display Adsense ads only when you want to

Do you ever wondered why some blog don’t use adsense becaue they thing the revenue is too low, while some other are very happy with it? The answer to this question is simple : Adsense work with keywords contained within the page. If the page have keywords that pays well, then you’ll make money, otherwise, your Adsense revenue will not be more than a few cents per day.

Are you still using Adsense ads on your blog? Whatever what you answered to the previous question, if you have an Adsense account, then this trick is for you.

[tweet]What you need is a WordPress (self hosted) powered blog, an adsense account of course, and some ability to modify WordPress files.

How to do it

First, you have to insert the following code to your function.php file. This file can be found on your theme directory (For example: If it doesn’t exists, just create it.

Don’t forget to change the adsense code, unless you’d like to display my ads on your own site!

function showads() {
    return '<script type="text/javascript"><!--
    google_ad_client = "pub-3637220125174754";
    google_ad_slot = "4668915978";
    google_ad_width = 468;
    google_ad_height = 60;
    <script type="text/javascript" src="">

add_shortcode('adsense', 'showads');

Once you inserted the code and saved your functions.php file, you’ll be able to embed your adsense code on your posts and display it exactly where you want. To do so, simply paste the following code on the editor, in html mode:


Pros and cons of this method

The obvious good side of this method is that it let you insert your Adsense ads exactly where and when you want it. For example, if you wrote a post about “Making Money Online” you may display some Adsense ads. On the other side, if you wrote a post about WordPress (A keyword that will make you earn just some cents), you shouldn’t display any Adsense.
If you detect that a particular post don’t bring as much as expected, you can remove ads on this post only.

The bad side of this method is that you have to manually insert your ads in each of your posts, and of course, there’s a risk that you forget to do so. Also, if you remove the code from your functions.php file, you’ll have to manually remove the [adsense] codes in your posts.
Also, don’t forget that Adsense terms of services forbids you to use more than 3 ads block per page.

I haven’t started to use this tip on CatsWhoBlog yet, but it gave me good results on some other blogs of mine. Anyways, you have nothing to loose, especially if you decided to drop Adsense from your blog.
Let me know about your questions if any, and your feedback about this method is definitely appreciated!

Tags: ,
Published on October 23rd, 2009 by Jean-Baptiste Jung

Leave a Reply