How To: More Targeted AdSense Ads & Thesis Code Example

If you have watched the Matt Cutts video from WordCamp San Francisco 2009 you probably noticed his mentioning of the two following HTML codes:

[html]
<!–google_ad_section_start–>
<!–google_ad_section_end–>
[/html]

Most people don’t know about those two tags and so they don’t use them. Using them lets you define what part of your website (or blog) should be used to tell AdSense the kind of ads you want displayed.

For instance, I currently have a teaser on my TechPatio frontpage that mentions a really fast gunman and so my AdSense in the sidebar shows an ad for “gun safety”, even though that’s not really relevant for my tech blog. That was just an example, imagine if you did a post on how to perform better in the search engines and you would like AdSense to show relevant banners, but because you have a good friend’s link in your blogroll about baby diapers, AdSense might pick up on that and display an ad for diapers instead – thus you probably don’t get any clicks from webmasters on those ads.

Using the two above mentioned HTML codes, you can make sure that AdSense only use the content within those two tags to define the kind of ads you want – in this case, the content of your blog post.

To do that in Thesis (a killer SEO optimized WordPress theme, click here for more information!), you simply need to edit your custom_functions.php file which you can locate in /wp-content/themes/thesis_151/custom, you can get there using a FTP program and connect to your webserver.

Add the following lines of code:

[php]
function adsense_before_content() {
echo "<!–google_ad_section_start–>";
}
add_action(‘thesis_hook_before_post_box’, ‘adsense_before_content’);

function adsense_after_content() {
echo "<!–google_ad_section_end–>";
}
add_action(‘thesis_hook_after_post_box’, ‘adsense_after_content’);
[/php]

That’s all there is to it, I hope it works for you 🙂

15 thoughts on “How To: More Targeted AdSense Ads & Thesis Code Example”

  1. This is the first time I know about these html codes. It’s really good to show targeted ads on a blog. Can these codes be inserted in a thesis theme only?
    .-= Marlene´s last blog ..Men In The Tube =-.

    Reply
    • Hi Marlene, nice to see you here!

      The codes can be inserted on any website pretty much – it’s just a matter of how. You might have to go into your theme and edit the theme files that displays the actual blog posts, to wrap those two HTML tags around the section that prints the actual content, so blogrolls/menu items etc. doesn’t affect your AdSense.
      .-= Klaus @ TechPatio´s last blog ..Facebook Lite: Facebook On A Diet (Updated With Screenshots) =-.

      Reply
  2. Helpful post. Unfortunately I was long banned from using Adsense for gaming their system. 🙁
    .-= Melvin´s last blog ..Look, We’re Not Idiots Here =-.

    Reply
  3. I use those tags only around 30% of the time I write a post 🙁 I should have done it more often but I’m just being lazy *sigh*
    .-= Michael Aulia´s last blog ..Weekend Fun: 10 Reasons to have a Geek as a boyfriend =-.

    Reply
  4. Great sharing that Klaus. The tags really help IMO.
    Oh and hey Michael ! This is Ryan the LT owner. Nice to see you here.
    .-= Webmaster Forum´s last blog ..Best small web hosting companies =-.

    Reply
  5. Hey ,

    I just found you out while googling , and this a really nice blog. 🙂
    You can use plugins to target the tags or even the content.Without these quotes placed properly , google ad scrip will scan the whole page for keywords.

    Expect me to be a frequent visitor here. Will read all your posts
    Thanks ,

    Regards ,
    Sourish
    (Admin)
    OneTrickADay
    .-= Sourish Nath´s last blog ..Take Screenshot of your Nokia Phone =-.

    Reply
  6. It means that you can use your targated keywords to get more profit. Cool idea.
    .-= Ricky´s last blog ..OMG!! My Twitter Account Got Hacked. [How to]Restore Hacked Twitter Account =-.

    Reply
  7. I have problems to hit $200 from adsense. I hope this tags can help me break the $200 figure. Thanks for sharing it.
    .-= Steve Yu´s last blog ..How to Add Emoticon List in Facebook Chat Window? =-.

    Reply
  8. That’s a nice little tip Klaus. I may have to use that one for my loadofbullsh#t site. 😉
    .-= Sire´s last blog ..Obama’s Health Care Plan Not At All Popular =-.

    Reply
  9. Thank you for the post. I will try this inmediately!!
    .-= arquigarfico´s last blog ..Add an Antique Sepia touch to your photos with Photoshop. =-.

    Reply
  10. Hi,
    Indeed these are all great things to do to your blog. I have recently started my blog and have learnt a lot over the last couple of months. There is so much more to learn still. Thanks for the info.

    Reply
  11. I never heard about this code yet. I wondered that Matt Cutts shared it in that conformance and not anything written on the official Google Adsense blog or anywhere?

    Reply

Leave a Comment