If you are wondering how AdSense shows ads on your blog, than the process is very simple. They crawl your blog and get the most related keywords, these keywords will be used to find the targeted adsense ads for your page.
But is our whole page is relevant for the ads, we do keep lot of things in our sidebars and footer and we might not want these to be targeted for AdSense ads. Here is an easy way to get the targeted AdSense ads for your content.
Before you go any further you need to understand that “It is against Google AdSense program policies to manipulate the ad targeting to result in ads that are not relevant to the content of your pages.”.
So as long as you are doing this to get targeted adsense ads related to your content it is fine, but if you manipulate it in such a way that you target high CPC ads without the relevant content it can be counted as a violation of Google AdSense policy. If you want more details on this you can check their official page.
Image Credit: renjith krishnan
Now Lets see how we can tell Google which part of your page they need to target. Google provides codes to mark a start and end section for which you want them to target ads, below are the code:
<!-- google_ad_section_start –>
<!-- google_ad_section_end –>
You can also tell them to ignore the specific section with the below code:
<!-- google_ad_section_start(weight=ignore) –>
Now lets see how we can use this with the help of hooks in thesis (Thesis provides an awesome way to implement things with the help of hooks, If you want more details you can check here.).
If you just want to implement it, you can copy paste the below code in your custom_functions.php. If you want more details then keep reading.
//adsense targeting functions
function open_adsense_targeting() {
if (is_single()) { ?>
<!– google_ad_section_end –>
<!– google_ad_section_start –>
<?php }
}
function close_adsense_targeting() {
if (is_single()) { ?>
<!– google_ad_section_end –>
<!– google_ad_section_start(weight=ignore) –>
<?php }
}
function ignore_adsense_targeting() {
if (is_single()) { ?>
<!– google_ad_section_start(weight=ignore) –>
<?php }
}
function end_adsense_targeting() {
if (is_single()) { ?>
<!– google_ad_section_end –>
<?php }
}
add_action('thesis_hook_before_header', 'open_adsense_targeting' );
add_action('thesis_hook_after_header', 'close_adsense_targeting' );
add_action('thesis_hook_before_html', 'ignore_adsense_targeting' );
add_action('thesis_hook_before_headline', 'open_adsense_targeting' );
add_action('thesis_hook_after_post', 'close_adsense_targeting' );
add_action('thesis_hook_after_html', 'end_adsense_targeting' );
We have created 4 functions to give us flexibility to start, end and ignore the AdSense targeting.
Function Descriptions:
1. open_adsense_targeting – This function will end any existing targeting section and start a new section for Google adsense targeting.
2. close_adsense_targeting – This function will close any existing targeting section and open a new one with weight=ignore, which means a new section which will be ignored while targeting any ads.
3. ignore_adsense_targeting – This function will start a section which will be ignored while targeting any ads.
4. end_adsense_targeting – This function will end any open targeted section.
Setting Hooks:
So once you have these 4 function defined you can use Thesis hooks to divide you page into targeted sections.
I have tried to put hooks in an order it will be in effect, the aim is to target your AdSense ads for header and your content, so if you see we are opening a section at the header start and closing it after header ends, than we open a ignore section body starts as we want to ignore everything other than the post content.
Open a new section before the heading so it will take heading and post content into account and close it one the post is done. rest of the page will be ignored.
So you will get highly targeted adsense ads related to your content, but make sure you have enough content in your posts so that Google can decide which ads it can display.
Thanks for the code sanjeev, I’ll try it to my other thesis blog. Hope it will work
this method can implemented to another theme?
i have try it then its gone blank..
The initial functions can be but the action hooks which I have used are Thesis theme specific. So if you want to implement it in another theme you need to look for a way to insert that actions. Let me know which theme you are looking for, I may be able to check the code…
This is a very good tip.Although I am not using Thesis, but I am now seriously considering it. There is so much talk about it. The one that I have, inserts codes automatically as well at various places, so it suits me.
Thesis is a good framework and can make life easy as they have covered almost every place where you want to insert anything…It is one of the reason I have learned so much in WordPress CMS..
I will have to bookmark this page and refer to it when the time comes for me to put adsense on my site. Thanks for sharing this.
Hello Sanjeev, I think this code can also help blogspot blogs like mine, can you suggest in which place its suitable. I think the before post title and
You can use Google markups on Blogspot also but you need to manually enter the code. You can enter it before post title and can close it before it start loading sidebar.
Yes i read the post and i’m still not sure how and where to add the html code.
The code needs to be added to custom_function.php file in custom folder for thesis theme.
Good tricks Sanjeev… I was looking for something related to placing adsense on single post. But this would help me do it in smart way 🙂
Thanks, keep in mind that the content should be 500 words or more otherwise it may affect the fill rate.
This seems to be excellent findings as nowadays even Google use to track browsing habits of users who seems to be online in their Gmail Id. This helps them to display more relevant ads to increase overall click through ratio of any particular ads.
Yes, A page contains lot of static text and might not be relevant to contents. This trick can show ads related to the content.
Good suggestions here. I typically use Adsense Optimizer for my sites but just purchased Thesis and am trying optimize it.
Thesis is a good framework for WordPress, try with the code above and see if it increase your earnings.
I am using thesis but i have not placed any ads in between post but i think now we can use in thesis thankyou for your Tip.
Its more of getting targeted ads which can be at any place on your page. They will show relevant ads based on your content and will have more chance of getting clicks.
I have implemented it long time back but honestly it din helped me much..Specially Google cookie policy which shows as based on user browser cookies…It’s making it very less effective… I guess might work better for people who are using incognito mode..!!
Hi Harsh, Cookies method might slow the effort but at the end its the content which will be used to set them also. I agree it might work out better in incognito mode….
Really an informative post about targeting adsense ads . Your code is perfect to get required results.
Thanks for sharing your knowledge with us.
Regards,
Amelie Wakelin
Thanks Amelie, Hope this code has helped.
very interesting article, thanks for sharing.
It all looks Greek to me, Sanjeev. LOL
I’ve been using Thesis since the beginning of my blog and still need someone to hold my hand…
When I started it was Greek to me too, though I am more of a technical person but always worked on the other side (mainframes). I am also learning but like to do most of the things through coding. Being a technical background helps.
Sanjeev great tips and I am sure your code will help many new bloggars. I am finding the adsense relevant to your blog post.
Thanks Lalit, Aim is to help and get most of the Adsense Ads.
Good one. I have actually implemented this method but I think that your instructions here are better. Off to do some “coding”, lol. thanks!
Thanks DiTesco, I have used this code and looks like it is helping on my blog. hope this helps on your blog too.
I have implemented AdSense targeting in my blog. I have been doing this for some time, mainly because if someone leaves a comment and a commentluv link back to the site isn’t really related, then I don’t want to throw off my AdSense ads.
If you use Commentluv, there can be many links in the comment section. Also if there are many comments chances are your ads might not be targeted to your content. Nice way to remove this and target ads to content only.
I personally don’t think that any manipulations are necessary as soon as blog post are well optimized and target certain keywords. Many people get recently banned by AdSense for no reason, so adding extra code can cost you more than you can make.
Yes, if it is not done correctly or done with extra work (using only part of content of something like that), it can come under bad practices. but telling Google where your content is fine and these tags are made for that purpose.
Also if blog posts are not long enough, it can decrease the fill rate, so we need to make sure our content is min 500 words to have a proper fill rate.
Does your Adsense earning increase after applying this targeted adsense ads for thesis? I have put the code into my blog but it doesn’t seem to help.
Earnings will depends on the keywords CPC, this will just tell Google to target the content and ignore other part. I have seen few click worth of $1 after this which was not coming before, so I assume it has helped.
Thanks for this valuable information and after reading this post found this plugin very useful . however adsense optimizer is best option which i recommend to my friends and other online users. your plugin is also best as like adsense optimizer.
Adsense Optimizer is a great plugin for inserting ads in a post. I would also recommend that to the starters or the people who doesn’t want to dig into the code.
Hello,
Just wanted to let you know your share widget is covering your content. This makes it very hard to read. I almost just left but thought I would let you know.
Jon
Thanks Jon for informing me about the issue, I will check it. I appreciate your effort in letting me know about it.
Yea, definitely when you do mess with the php, backup is the most important thing to do before you do anything else.
Yes, it is most important thing. Also I have a same setup on my development server which helps in testing before putting changes live.
I recommend to use Adman plugin. This plugin will automatically insert ads into your post. I install this plugin for my blog.
I also used it at the start, but later on shifted to using hooks in Thesis. I found it easy and faster way to do that.
Sanjeev,
Thanks for the instructions. However, I never mess with the php files on my blog – I’m much too afraid I’ll break something. Right now I’m using a plugin called AdSense Optimizer and it’s doing all the heavy lifting for me. 🙂
I really like doing things through hooks and filter and thesis has been great in that. The above code is running on this blog so kind of safe.
I do take backups before making any changes and do test them on my development server first.
Comments are closed.