home

3 tips for effectively using Adsense in WordPress

March 16, 2010 · 5 comments

Adsense is one of the easy and effective way to monetize any website. I have been using Adsense ever since I started blogging and it gave me good returns too!

In my last post about Adsense, I had summarized some of my observations from using Adsense to monetize this blog. Long back, I shared a PHP code snippet to insert Adsense based on the post length. Today In this post, I’m sharing few more tips on Adsense, which I think might helpful to you. Here we go:

I assume that you are using WordPress and you know how to edit WordPress theme files. If not, you are using these code snippets at your own risk!

1. Target Adsense content and get better ads

Your blog might have n-number of things – comments, sidebars, ads, etc – apart from the main content. The user comes to your site to read your content, not the n-number of other things. So, it is better to target the main content to show best matching ads, which in turn increase the click through rate. This is called as Adsense Section Targeting. It’s an approved method from Google to improve the advertisement shown on your website.

For Section targeting, all you need to do is, put the following code snippet in your blog/website.

<!-- google_ad_section_start -->
Your main content / blog post.
<!-- google_ad_section_end -->

WordPress users can add the above snippet in their single.php file in appropriate place.

2. Show Adsense only to the search engine traffic

If you want to show the advertisements only to the users who are coming from a search engine (Google or Yahoo!), use this snippet. For wordpress users, in your single.php file place this code in appropriate place.

<?php
$ref = $_SERVER['HTTP_REFERER'];
$SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SE as $source)
{
        if (strpos($ref,$source)!==false)
        {
                echo 'PLACE ADSENSE HERE';
        }
}
?>

3. Add ad only to the older posts

In case you want to show ads only on the posts which are older than, say 10 days. This way you can hide adsense to the regular readers of your blog and still show advertisement to the people who are looking at your old posts. Well, here’s the code snippet for that.

<?php
  global $post;
  $DAYDIFFERENCE = 10;
  $postDate = $post->post_date;
  $currentDate = date('Y-m-d');
  $diff = abs(strtotime($currentDate) - strtotime($postDate));
  $diff = ceil($diff/86400);
  if($diff > $DAYDIFFERENCE ){
    echo 'PLACE YOUR AD HERE';
  }
?>

Related Posts

{ 4 comments… read them below or add one }

JB March 17, 2010 at 6:03 AM

Thanks for the tips.

Unrelated to the above post – In this blog, you show snippets of recent posts and again the footer has a section of recent posts. A section of related posts may be more helpful.

Reply

Veera March 17, 2010 at 1:00 PM

you are welcome, JB!

btw, I was having the related posts feature before, but disabled it because it confused the search engines and the search results were messed up. That was the only reason for not having the related posts in this blog.

Anyway, I’ve added the related posts now. Hope your experience with this blog gets better.

Reply

Jack April 23, 2011 at 1:52 AM

I do not like to copy and paste adsense codes. So, I use plugins at my blog. The plugin I use is Best Google Adsense
http://wordpress.org/extend/plugins/best-google-adsense/

Reply

Madushan December 21, 2011 at 12:52 PM

I’m using adsense within my posts. (ads look blended in with the post content) .
The ads are shown in top left corner with the post, top right corner of the post content.
My problem is, when i go to the blog’s homepage. Post ads are also shown there (only the ads above !–more– tag). since google doesn’t allow more than 3 content ads per page, we can’t allow this.

So i want to show these ads only in post pages but need to hide those in the home page.

I’ve tried using

— adsense code goes here —

but the post now shows

tags before showing the content. This means this php tags doesn’t work.
I’m NOT using a static page for the homepage. homepage is a combination of the latest posts.

see http://www.verilog.asia

Thanks

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: