AdSense

kbahey - May 26, 2005 - 04:16

The Google AdSense module provides Web site owners with the means to earn revenue from visitors by displaying ads from Google's AdSense service, or Google's SiteSearch on their sites.

Depending on the web site number of visitors and type of content, the revenue can barely cover the hosting costs, or be quite substantial.

Features

The colors are customizable, as well as the type (text/image). Ads can be displayed from within phptemplate based themes, blocks or other modules.

Several ad formats are supported, including SiteSearch as well. The full list is is in the help section of the module's settings page.

The modules allow up to 3 color and type (image/text) combinations to be chosen. This is useful if your site has a theme that assigns different color schemes to different parts of the page, for example, left sidebar and content. It also allows up to 5 custom channels to be used.

You can setup custom roles that hide adsense from users. For example, if you have paying subscribers to your site that do not want to see ads.

Some caching is also implemented by this module (thanks to Ber Kessels).

Page matching also added, so that ads can be excluded on certain pages.

Ads can now be placed anywhere in the content, via a special tag. This can also be used to call flexiblocks so fine grained visibility can be done using the block mechanism.

Revenue sharing

The module provides sharing of ad revenue with contributors who write articles on the site. The basic revenue sharing module provided allows for a configurable percentage of page views for specified content types to go to the node author, or the blog page author. It also integrates with referral module so referred user's node can get a certain percentage to the referring user.

Other methods of revenue sharing are possible using the API described below, such as:

  • Different percentages based on what taxonomy the node belongs to.
  • Different percentages based on what roles the user is a member of.
  • Different percentages based on how many userpoints the user has.
  • Using a CCK field for the the Google Adsense ID.

API

Starting with 5.x-2.x, the adsense module provides developers with an API that can be used to control the Adsense Client ID used for the particular page view.

You can decide to select a different Adsense Client ID based on the content type, the user's role, the level of user points, the taxonomy of content page, a monthly contest, rewarding users, connected to Google's API, or anything else imaginable.

To do so, your module must implement a hook called 'adsense', as follows:

Assuming your module is called: your_module.module, you will have the following function in it. The function has an $op argument that you should check:

<?php
function your_module_adsense($op) {
  if (
$op == 'settings') {
   
// Add here form elements for your module's settings
    // These can also contain markup elements for help text
    // These are standard FormAPI elements.
   
return $form;
  }

  if (
$op == 'client_id') {
   
// Here you can use whatever logic you want to select a Google Adsense
    // client ID
   
return $client_id;
  }
}
?>

See the adsense_basic.module for an example of how to write your own module.

After you install the module, it should appear on the adsense module settings page, along with other modules. You should be able to select it, and configure it.

Resources

Please read the module author's collection of articles on resources for using Google Adsense with Drupal. They contain hints and tips on how to use the module. If you have not signed up for a Google Adsense account, please use this link to signup, and a referral amount will be awarded to the author at no cost to you.

Installation and Configuration

Check the README.txt file or the online help for detailed instructions on installation, configuration and usage.

Upgrading

If you are upgrading from the 5.x-1.x to the 5.x-2.x series, there are a few things that you need to do:

  • If your site has no revenue sharing, then you need to also enable the Adsense Basic module, and click on the Settings link for it to enter your Google Adsense ID. There is no need to enable the Revenue Sharing Basic module.
  • If your site already uses revenue sharing, you need to first write down the revenue sharing settings, before installing the 5.x-2.x version of Adsense. You then need to enable the Revenue Sharing Basic module, and click on its Settings, and enter all the settings that you wrote down earlier.

Known Issues

The Garland theme has a bug which causes JavaScript code in the header region to be displayed. If you use this theme and intend to place ads in the header region, please check issue 102252 for a fix.

Author

Khalid Baheyeldin of 2bits.com.

The author can also be contacted for paid customizations of this module as well as Drupal consulting,
installation, development, and customizations.

Releases

Official releasesDateSizeLinksStatus
5.x-2.02008-Mar-0943.83 KBRecommended for 5.xThis is currently the recommended release for 5.x.
5.x-1.62007-Jul-0735.12 KBSupported for 5.xThis release is supported but is not currently the recommended release for 5.x.
4.7.x-1.02007-Feb-1219.67 KBRecommended for 4.7.xThis is currently the recommended release for 4.7.x.
Development snapshotsDateSizeLinksStatus
5.x-2.x-dev2008-May-1244.59 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.
 
 

Drupal is a registered trademark of Dries Buytaert.