We spent some time to add exciting new features to the adsense module.

New hook API

The module now has a new hook_adsense() that can be used by other modules to determine which Google Adsense ID to show. This allows virtually endless possibilities for revenue sharing.

Less dependencies

The module no longer depends on the core profile module. For sites that don't need revenue sharing, this means a far simpler setup and you can be up and running in a few minutes.

Better uninstall

An uninstall for all the included modules has been added.

Better help

Help is now easier to maintain in separate files with plain HTML in "here docs" rather than embedded in PHP.

Adsense Client ID selection modules

The adsense module detects other modules implementing the hook described below, and lists them in its settings page, allowing the site admin to select which one to use.

More details on the API

The adsense module now 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(s), the number of userpoints, the taxonomy of the content page, a monthly contest, rewarding users, connecting 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:

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 included 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.

Download the Adsense 5.x-2.x tarball (available shortly).

Is your Drupal or Backdrop CMS site slow?
Is it suffering from server resources shortages?
Is it experiencing outages?
Contact us for Drupal or Backdrop CMS Performance Optimization and Tuning Consulting