Test Adsense on your WordPress blogs

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
February 17, 2009

Adsense is by far the best and the easiest tool to monetize your site because its easy to integrate and provides relevant ads for your website. You can easily place ads on your site by putting Adsense Javascript code snippet in the html of your site or blog. If you use WordPress, there are a number of plugins that are available for inserting Adsense. These tools allow you to insert adsense very easily without having to put the whole javascript code in your templates or on your posts inline. But what if you want to test Adsense on your site trying them at various spots on your blog so as to generate more clicks? If you repeatedly open up your site for testing Adsense, or just for previewing a number of your posts, visiting as a normal user, you’ll make a number of impressions to the ad which Google Adsense won’t entertain. And there are chances for accidental clicks as well. So, how will you test adsense, the legitimate way on your blog? Well here’s how you do it.

As mentioned earlier there are a number of plugins available for WordPress to place Adsense on your blog. A simple trick to test Adsense on your blog is modifying the Adsense code a bit by adding a line google_adtest = “on” within it. A plugin called All in one Adsense and YPN automatically adds this while you are viewing your page but it doesn’t has much customization options. Well you can insert it to test Adsense like this:

<script type=”text/javascript”><!–

google_ad_client = “pub-1258251340217157”;

/* 336×280, created 2/15/07 */

google_adtest = “on”;

google_ad_slot = “3183989118”;

google_ad_width = 336;

google_ad_height = 280;



<script type=”text/javascript”



You just need to insert it somewhere inside the Javascript code like shown above. But with this code inserted within the Adsense code, not only yours but the impressions or the clicks made by the real visitors to your site will also not be counted. So, you won’t be making any money. To avoid this, you need to make changes such that you can test Adsense on your blog only when you are visiting your blog as its owner. To do this, you’ll need to modify your template a bit. But if you insert adsense inline with your posts, this won’t help.

Now open up your template file where you have inserted your Adsense code. It can be the header.php, sidebar.php or any other. Now edit the code as follows:

<?php if (is_user_logged_in()) { ?>

<Your Adsense Javascript Code with google_adtest = “on”;>

<?php } else { ?>

<Your Adsense Javascript Code without google_adtest = “on”;>

<?php } ?>

When you do as above, save your changes. Now, you can test Adsense when you are logged in as the admin of your site and at the same time you won’t lose any clicks from your visitors.

But inserting the full javascript code can be a bit troublesome if you have many ad units in your blog. So, use Adsense Deluxe, one of the most popular Adsense plugins for WordPress.  Once you install the plugin, you will find all the instructions for using it in its options page inside your wordpress admin. To turn on adsense_adtest =”on”; for the plugin is also very easy.

Once you specify the name for your adsense block, insert the Adsense code and save it and you are ready to get started. Your default ad unit will be named “adsense”. Note that while you are using the names on your template files, you shouldn’t enter it as specified in the plugin. For adsense it will show <!—adsense—> and if you give it some other name like myads it will show up in the plugin window as <!—adsense#myads—>. In the latter case the name you’ll be using in your template would be just myads. Now create another Adsense ad unit with the same Adsense code but with google_adtest = ”on”; inserted. This will be used as an alternate ad unit that will serve for testing Adsense. Then name it “adsense_test”. Now to to place your adsense block in the desired place, just insert the following code in your template.

<?php if (is_user_logged_in())



} else {




This will turn on the Adsense test only when you view your blog as the admin. Using the plugin will make it much easier to add the ad units to your blog and manage them. And with the above trick, you can easily test Adsense on your blog without alarming the Adsense system. So, next time if you ever need to test Adsense on your site, do it without violating the Google’ Adsense TOS.

You may also like...