Google AdSense Referrals are pretty cool in a way as they contribute well in topping up on your daily AdSense earnings. Moreover, they’re quite unobtrusive and can be placed anywhere on the page without interfering with the content much. According to me they’re best placed in the side-bar and since I’m using a widget enabled theme I got down to searching for a widget plug-in that would let me to do just that.
If you don’t know how a AdSense Referral looks like, here’s a snapshot…
Anyway, I found plenty of AdSense widget plug-ins that allow you to display the text-ads anywhere on the side-bars. None of the plug-ins I found were cut-out for Referral Ads only, but with some minor modifications one could use the available ones to show referrals too.
Google provides you with 4 different kinds of referrals at the moment and my idea was to keep rotating between all of them randomly, thus presenting your visitors with a wider range of choice to pick from. Unfortunately, I couldn’t find a single one in this category and hence with whatever limited knowledge of WordPress I have, I got down to writing one of my own. The idea was to use the mt_rand function of PHP which …
“uses a random number generator with known characteristics using the Mersenne Twister, which will produce random numbers four times faster than what the average libc rand().” provides.
… and generate a number between 1 & 4 and use that number as a key to an array holding the google_cpa_choice code for the four different referrals. Pretty easy, eh ? Every time a visitor loads the page containing this widget in the sidebar, a new random number is generated, thus showing a different referral (most of the time). I say most of the time here, since occasionally the generated random numbers might overlap showing the same referral consecutively for a couple of times.
When it came to the implementing the idea part, I was at a total loss as I’d no clue about writing sidebar widgets. However, I’m extremely adept at making meaning out of existing code and modifying it to suit my purposes. I acquired half my PHP knowledge that way. So even here, I picked a AdSense widget plug-in that seemed the easiest to decipher and recode. The plug-in I chose was Google AdSense Widget written by Mike Smullin. It took me about half-an-hour to read through the code and another one hour to get it to do what I wanted. The result was GARR or Google AdSense Referral Rotator, which I’m sharing with you here.
- WordPress Sidebar Widgets Plugin in case you’re using WordPress 2.1.x or below.
- None, if you’ve WordPress 2.2.x installed.
GARR (2.7 KiB, 1,446 downloads)
- Installation is really easy. Unzip the file and upload the contents to your /wp-content/plugins/ directory.
- In the Administrative Control Panel, go to the Plugins tab and Activate the widget.
- It will now show up in the Sidebar Widgets screen under the Presentation menu. It’ll be located in the spare widget tray. You can simply drag and drop it on to any sidebar you wish.
- Once placed in a sidebar you’ll notice a small icon next to the widget title. Click on that to open the configuration panel. Here’s a screenshot of the panel…
- Enter your AdSense client ID (google_ad_client) here.The default referral ad size (google_ad_width x google_ad_height) is set to a small button 120 x 60 pixels. You’re free to modify it any of the other standard sizes supported by Google.Make sure you modify the google_ad_format too in case you change the width and height. The available referral ad formats can be viewed by logging into your own AdSense account and visiting this page.
- You’ll notice a separate section below the general parameters with four fields titled Referral#1, Referral#2 and so on… they contain the ad code for the four different referral types available through AdSense at the moment.If there are further referrals added in future, I’ll upgrade the plug-in to reflect that. In fact I’ll try to modify the widget to enable users to add as many referrals as they want.
- Once done with your settings, click on the close (X) button and Save the settings…and you’re done.
Now your widget will show up in the sidebar and display different referrals on every page load.
Comments & Feedbacks are more than welcome… 🙂
I offer support for my plug-ins via the Chaos Laboratory Support Forum only. I will NOT respond to support queries left in the comment section below and, in most cases, will also not publish them. Of course, if you’d like to say something nice or helpful, then feel free to leave a comment!
Since Google Adsense Referrals have been retired for a while now, this plug-in is of no further use and is discontinued.