How To: More Targeted AdSense Ads & Thesis Code Example

by Klaus on September 12, 2009

in Thesis

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 🙂

Comments & Leave a Comment

comments

{ 15 comments… read them below or add one }

Marlene September 12, 2009 at 22:30

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

Klaus @ TechPatio September 12, 2009 at 22:34

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

Melvin September 13, 2009 at 04:24

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

Michael Aulia September 13, 2009 at 08:18

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

Ryan, Webmaster Forum September 13, 2009 at 11:08

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

Sourish Nath September 13, 2009 at 21:15

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

Ricky September 14, 2009 at 15:55

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

Steve Yu September 15, 2009 at 12:21

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

Klaus @ TechPatio September 15, 2009 at 17:49

I hope that’s $200 a month cause that would be great for you 🙂

Reply

Sire September 16, 2009 at 08:19

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

arquigarfico February 2, 2010 at 21:13

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

Pogoda October 18, 2010 at 10:18

Nawet nie znałam to. Dziękuje bardzo 🙂

Reply

Sourish October 18, 2010 at 18:00

what is that supposed to mean ??
Sourish recently posted… VLC Player Remote Control using iTouch 4 iPhone

Reply

[email protected] May 3, 2011 at 00:01

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.
[email protected] recently posted… How To Add Pagination In Any WordPress Theme Without Any Plugin

Reply

Amit November 25, 2012 at 17:32

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?
Amit recently posted… Bitdefender Windows 8 Security | First Dedicated antivirus for Windows 8

Reply

 

Leave a Comment

CommentLuv badge

Previous post:

Next post: