The Easiest Way To Add Google AdSense On A Blog

After the number 1 question of what webhost do I use to host this blog, the number 2 most asked question is, “How do you set up the Google AdSense ads on your blog?” This question comes up a lot because the reader notices that my blog always limits the Google ads to three (Google’s limit). So, if you scroll pass the first two posts on the front page, you won’t see any more Google ads. However, if you click on any of those posts, the inline Google ad will appear inside the post.

This is a good time to remind readers that this blog has a search function and a Top Posts page. Before emailing me a question, you should try doing a search or check out the Top Posts page because there’s a chance I already written about it. In the case of the number 2 most asked question, I have written about it before. However, I’m going to use this post to explain it more.

AdSense Deluxe

Click for full size image

The AdSense Deluxe WordPress Plugin is what I use to control the Google ads you see on this blog. The Plugin, which also works for Yahoo Publisher Network (YPN), is extremely easy to install and use. Just download, unzip and upload to your plugins folder. The plugin will place the above Adsense Deluxe screen to your WordPress options panel. From there you can create multiple AdSense ad units and decide what parts of the site should have or not have ads, and what ad sizes to run.

In the above screen shot, you can see I have three AdSense ad units listed; 468, bottom and default (which is a 300×250). The easiest way to integrate AdSense Deluxe into WordPress is by editing the index.php file of the theme template. To make the Google 468 show up at the top of every page on the blog, I just add <!–adsense#468–> to the part of the template where I want the Google ad to appear. The same goes for the bottom Google ad, which I currently do no run.

To get a Google ad to show up inside a blog post I just insert <!–adsense–> at the spot where I want the ad to show up. To align the ad to the right and make the text wrap around the Google ad, I use this table command: <table align="right"><tr><td><!–adsense–></td></tr></table>. Just change it to align=”left” if you wish place the ad on the left side.

*Update – Thanks to Tam Denholm for this. For cleaner HTML, use a div command: <div style="float: right; margin: 5px;"><!–adsense–></div>. The margin adds a bit space around the AdSense unit.

The Plugin will keep track on the number of AdSense ads running on the page and limit that number to three. This is why you will not see a 300×250 inline Google ad on all the front page blog posts, but the ad will show up when you click to read the post. Another nice feature of AdSense Deluxe is the ability to globally enable and disable ads. I can turn on or off all the Google ads on this blog with just a click on the mouse. Alternatively, I can just turn off the ads in the home page or individual posts only. The plugin has tons of options.

If you’re going to run Google AdSense on a WordPress blog, then AdSense Deluxe is a must have plugin. The next time someone sends me an email about how I do my Google ads, I’ll just send him or her the link to this post. 🙂

38 thoughts on “The Easiest Way To Add Google AdSense On A Blog”

  1. Brendan says:

    You may also put the adsense code in a layer and use the float attribute in CSS. You can put it right where you put your adsense code so all you have to put in each post is

  2. Brendan says:

    Looks like it didnt show up but the last word was the part.

  3. Tam Denholm says:

    If anyone here is a little more concerned about html quality then rather than use a table:

    …you should use a div and float it instead:

    Obviously changing the float to left if desired. The margin just adds a little space around the adsense unit.

    Mind you, anyone that IS concerned with html quality, would know how to do this anyway, i just thought i’d bring it up.


  4. Tam Denholm says:

    HTML was stripped…

    Heres the examples again in htmlentites, if it doesnt appear correctly, please delete the post John.

    If anyone here is a little more concerned about html quality then rather than use a table:

    <table align=”right”><tr><td><!–adsense–></td></tr></table>

    …you should use a div and float it instead:
    <div style=”float: right; margin: 5px;”><!–adsense–></div>

    Obviously changing the float to left if desired. The margin just adds a little space around the adsense unit.

    Mind you, anyone that IS concerned with html quality, would know how to do this anyway, i just thought i’d bring it up.


  5. John Chow says:

    Tam Denholm – Thank you. Your way is better!

  6. Victor says:

    I just put the Adsense in the WordPress “loop” inside the main page template…this inserts the ads between the articles. This works out for a multi-author blog which translates to no effort on the user’s end.

    Google’s Adsense seems to be self-throttling. Despite being in the loop, only three ad units show up, regardless of how many articles are on the page.

    However, I do like the tight integration of having the ads inside each article, placed for optimal CTR. Maybe a future version of the plugin will have drag-n-drop Ajax goodness?

  7. Matt $tidham says:

    The perfect post at the perfect time. I was planning on adsense’ing my site this week. Thanks John

  8. thanks for the Info John. great work.

  9. Doug Karr says:


    I found a great resource tonight for integrating Adsense with Google Analytics.

    It appears you’re utilizing Google Analytics so it may come in handy!

    Warmest Regards,

  10. Kenric says:

    Thanks John, I’ve been using that plugin ever since I read about it on your blog. It’s great.

    Now if I can just figure out why the ads on my main page are always the same even though my posts are on different topics everyday.

  11. Yan says:

    I have been using it for a while and the only problem I have is that I need to disable character encoding for the posts with google ads insets. Otherwise the adsense code snippet gets corrupted (the line-breaks are replaced with “”.

    A great plugin otherwise!

  12. Yan says:

    The HTML-code didn’t show up in my comment

    I meant to say that line-breaks inside the javascript are replaced with the HTML equivalent of new line which corrupts the javascript code.

    Does anyone have a solution for this (other than disable character encoding)?

  13. Ajay D'Souza says:

    Don’t you have to add this code manually to the posts / pages?

    I really hope there was a way for random insertion of ads to the post.

  14. Bill says:

    Thanks for writing this post John, I’m going to try this plugin. 🙂

  15. Leonard says:

    I’m currently using an improved version of adsense deluxe. The improvement is on the ad limiting algorithm.

    Changes from the original version:
    * Added adsense unit type option (Ad Unit, Ad Link, Search Box, Referral1, Referral2, Referral3, Referral4).
    * Fixed adsense unit limiting algorithm, now units per page limit is based on unit type
    * The limits are: 3 for Ad Unit, 1 for Ad Link, 2 for Search Box, 1 for each Referral

    You can check it out here –

  16. HMTKSteve says:

    Or you could just use something else like I do, read your PHP code and insert the AdSense code on your own.

    I am often amazed at how many people have websites yet have zero understanding of how their website works.

    You wouldn’t buy a car with the hood welded shut would you?

  17. Jez says:

    Hi Yan,

    To insert line breaks use the html view and insert

    You need to make sure this is within the correct tags.

    HMTK Steve,

    the advantage of using this plug in is that you can mix and match which blocks you use in each post, and edit those blocks more easily from the WordPress admin panel, as opposed to FTP’ing changes or messing around trying to load the correct file path into WP.

    I hard code changes into template files, but use this plug in for code inserted into posts.

    It is also worth re-validating your HTML after making these changes, I found some of my adsense blocks failing to validate using the W3C tool.

    Tan Denholms comment on using div tags is a good one, if you want it to validate using the W3C tool (xhtml link in the META sidebar) then I found it necessary to add either side, i.e.

    My site ( also uses mistylook, and the same adsense suggested by John, but it still valid XHTML, which Im afraid this site is not 🙁

    Unfortunately I am stuck with only a few AdCents for my efforts, a post on improving traffic would be a help 🙂

  18. Jez says:

    Hi Yan,

    My code got stripped, take out the ‘ from below

    You need to make sure its properly within the p tags, the same goes for Tan Denholms code, I found I needed a closing p before, and an opening after the div, i.e. keep it outside of any p tags.

  19. Jez says:

    Yan, third time lucky with the line break code, sorry John:

    <code><br /></code>

  20. Tyler says:

    I’ve been looking into more the Google Adsense thing.

    I haven’t quite put my AdSense links within the posts like John does here but perhaps I’ll do that. Currently I just add them at the bottom of the entries.

    Of course I don’t get the traffic of this site, but perhaps one day I might, who knows!

    This whole blog and SEO thing has been tool in leanring more about things on the web. Being able to create my own blog via PHP/MySQL etc has been a great asset as well.

    Now to figure out the best way to put ads so they are not obtrusive and annoying.

    I’ll have to try out that little trick with AdSense and Analytics, since I currently don’t really track any of the clicks like I probably should.

  21. HMTKSteve, I’d be willing to bet a lot of people buying a car would not even know that their hood was welded shut until the mechanic told them so on their first maitenance visit. 🙂

  22. Dave says:

    FYI – In my setup, I created different groups for centered and float right/left. This better allows me to track which version is performing better. You can setup the DIV code IN the adsense code when setting it up in the AdSense Delux options page.

  23. derrich says:

    I actually use my AdSense Deluxe to insert my LinkShare ads into my posts. I just call them “” or something along those lines, and in the comments add a small description of what the ad displays. So, I’m not sure how many of you also use other ads, but ASDeluxe can be used for other ad networks as well. Makes it easier than having to go to the ad network to get your ad code each time. Just a thought.

  24. Bryce says:

    How do you only display ads on certain posts on the homepage?

  25. Jojo says:

    thanks for the info. I don’t know that we could just write the code snippet into the index.php for the AdSense to appear at the main page. I thought we could only use it in the blog post.


  26. Reckless says:

    Nice plugin, i’m going to use this on my blog

  27. Muhammad says:

    Hi jhon i have a site base on a forum made by invision power board i have 100000 page impression using google adsense from last 3 years but now a days my page ecpm become half as compared in past and my earning down alot there is unrelevant ads displaying on my site i am using two 468*60 banners on each page can you please help me in any way thanks …

  28. Ismu Surizan says:

    too bad … this plugin can’t limit the number of ads to 3 as per adsense TOS.
    though, it’s great to insert ads into blog post.

  29. John Chow says:

    Ismu Surizan – The Plugin does limit the number of Google ads to three.

    Muhammad – This post should help you:

  30. Ismu Surizan says:

    I don’t know what I did wrong … but if I open the HTML source … this plugin still convert the ads even though there are already 3 ads …

    Well, I just use it to insert ads inside post … for everything else … I simply modify the theme and use generated code from google …


  31. Milan Dinic says:

    John, how do you add 300×250 ad inside posts: by inserting code in post text or by inserting code in template file?

  32. John Chow says:

    It’s inserted in the post text.

Comments are closed.