I just committed a new module to the repository. It allows web site owners to run Google AdSense ads on their web sites, thus making some money.

Here is the announcement and here is the project page.

Comments

kbahey’s picture

The module is now updated to provide the following:

Added up to three different type (image/text) and color combinations. This
is useful if your site has different color schemes for different parts,
such as left sidebar, center and right sidebar.

Caching as per Ber Kessels suggestion http://drupal.org/node/23655

Up to 5 channel IDs as per this feature request http://drupal.org/node/23719

Uses Drupal permissions and hence provides creative usage based on role. For example, paying subscribers to your web site can be exempted from seeing ads.

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

weblogrrl’s picture

I tried adding this module in this site - http://chrysaliscreativity.com/portal/
- but it's not showing up. It will only show the placeholder (if I activate the placeholder). Otherwise, it comes up empty. I added it both as a block and as part of the page template (php).

I used this code in the block (php):

if (module_exist("adsense"))
{
 print adsense_display("160x600", 1, 2);
}

And I used this in the page template -

print adsense_display("160x600", 1, 2);

What am I missing here?

kbahey’s picture

I looked at the page you linked to, and I can see the ads.

The ads will not show for the site admin. This is by design, so that you surfing your own site would not skew the ad statistics. If you log off, hence becoming Anonymous user, you will see the ads.

Another thing is that for new sites, Google may not display anything, because your site is not yet in Google's search index, so it does not know what type of ads to display.

Another possibility is that there are too many ad units on the page, and Google has already displayed the most it can display, hence leaving some units empty.

You need to view the page source and see if the ad javascript is displayed. There are comments in the code that tells you what is going on. For example, I see this in the second ad, but not the first:
<!--adsense: cached-->

This tells me that perhaps you are using the adsense for the 2nd ad but not for the first (perhaps hardcoded in the theme?)

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

venkat-rk’s picture

Hello Khalid,

I always ignored Google Adsense until recently when I was convinced about its potential. Imagine my surprise when I saw this module.

Thanks for helping people like me through your efforts. Much appreciated. One day, I will give back to Drupal in some manner.

kbahey’s picture

Well, the amount of money you make really depends on your specific situation: The type of site you run, the number of visitors, the audience, ...etc.

It can be a few tens of dollars per month, barely covering the cost of hosting and bandwidth. Or it can be substantially more, depending on many factors.

To me, it is a worthwhile experiment, not for the money (though it helps), but rather seeing the net economy in action, and tweeking things to see their effect.

The module started out as a set of functions in template.php for the phptemplate based theme I was using, then in a matter of two evenings, it evolved into a full fledged configurable module. I wanted it to be easy to setup (not requiring database changes, no external setup for the module) so more people get to use it and benefit.

I am sure there are sites that will make money from this module (Hello guys! I will take a cheque!). How much really varies. It is not a sure way to get rich by any means.

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

green monkey’s picture

you have made this module so very simple to use, I can't believe i can't get it to work.

I'm trying to get it to work in a block.

this is all I see in the page source

</td><!-- mainContent -->
				<td class="sidebar" id="sidebar-right">
				<div class="block block-block" id="block-block-3">
  <h2>adsense</h2>
  <div class="content"><?php
if (module_exist("adsense"))
{
 print adsense_display("120x600");
}
?></div>
</div>
		</td>

... as you can see i even tried to strip it down to the basics and let it decide ad type (1 default)

I have a ID# added in the settings and even did a test to be sure I had the right ID# - by pasting googles syntax into a Block (the way i use to run it)

any ideas what I'm not seeing? running on 4.6.1

kbahey’s picture

Seems that the format type for the block is not set to PHP.

Try that and see.

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

jauhari’s picture

On my site this AdSense Module doesn't work Just Blanks and on my source just like this

<!--adsense: nothing -->

Please give me solution.

Thanks

http://fitriarich.com

green monkey’s picture

ok, please don't laugh - I do this by using the the PHP code filter when I submit it correct?

if so this is what I get

</td><!-- mainContent -->

				<td class="sidebar" id="sidebar-right">
				<div class="block block-block" id="block-block-3">
  <h2>adsense</h2>
  <div class="content"><!--adsense: nothing --></div>
</div>
		</td>

and here is what I used

<?php
if (module_exist("adsense"))
{
 print adsense_display("120x600");
}
?>
kbahey’s picture

Well, this was a bug, and not something you are doing wrong. The page matching logic was not working as expected.

I fixed it.

Either wait till tomorrow and download it again, or if you are impatient, then download it from here.

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/adsense/

jwells and fitririch, please submit issues next time around. I may have missed the posting in the forums.

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Darsarin’s picture

When I try to add a 2nd google ad block I get this.

Duplicate entry '' for key 2 query: INSERT INTO boxes (title, body, info, format) VALUES ('Feed me', 'php print adsense_display(\"160x600\", 2, 2); ', '', 2) in /my path info/includes/database.mysql.inc on line 66.

p.s. I had to remove the php inclue's to post this but they are in the error message.

Darsarin
www.youwillneverbelievethis.com

kbahey’s picture

This is not an adsense issue.

All you need to do is to make each block have a title. You cannot leave more than one block with a blank title.

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Darsarin’s picture

My current block has a title. I was trying to add a second block with a different title.

Darsarin

green monkey’s picture

Thanks, the program code was so darn clean and if i have picked up your style you look at things several times before making them public. your "open bugs" speaks for itself ... there usually isn't one. :-)

so, I naturally assumed I was goofing it up somewhere or another module was stepping on it somehow.

I can open a issue next time per your request, it does keep the forum much neater. I was just thinking it was me and not you and found this thread, so i thought attaching here would be more apporiate.

Thanks again

kbahey’s picture

Actually, it is my fault. Some helpful soul submitted a patch to improve some things in the module, and I did not test it fully before committing. Also, I did not eat my own dog food and upgrade my sites to that latest version.

If I had, I would have discovered this bug quickly.

There was a silver lining though: I rewrote portions of the code in the patch to be clearer and more readable (I hate those multiple conditions in if statements, some with ! and some with not, some with || some with && !)

--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

topofcool’s picture

Just what does the "adsense: cached" thing mean. That's all I'm getting and I can't figure out what it means.

kbahey’s picture

Clear the cache by doing either of the following:

1. Visit admin/settings/adsense, the clicking Save.

2. From phpmyadmin, run this SQL:

DELETE FROM cache WHERE cid LIKE 'adsense%';

After that, access your site as an anonymous user (i.e. log out first), and see if you can see ads.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

topofcool’s picture

Hm...doing both of those steps results in an empty block. Strange.

This is my site, if that helps any.

kbahey’s picture

The HTML tags are being mangled. For example the < is being displayed as &lt;

All I can say is check the format of the block, make sure it is PHP. Also check the filter configuration (admin -> input format).

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

topofcool’s picture

OK, I had a filter active that wasn't useful in that context.

Of course, the colors are now hideous, but that's easier to fix. ;)

kbahey’s picture

Just in case someone else faces the same problem, please open an issue for the adsense module, and describe the problem, and how you fixed it. Then mark it as fixed.

This way if someone searches, they will find the answer.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

dolphinsdock’s picture

Hello, I've got adsense running just fine in IE but they don't display in FireFox. Any suggestions?

green monkey’s picture

are you logged in as Admin?

I had to ask... I've done this a few times - "Oh no ... where the Ads go?" :-) I use FF and haven't seen a problem yet

nexusone’s picture

I am in the midst of a migration from Joomla to Drupal. At this point I'm just fleshing out the framework and core features. Last night I installed the adsene module to get my ad units online prior to making a push to finalize look/feel and pull all my content over.

Weird thing is that the ads show up fine in IE6, but not in firefox. Logged out from admin. I know how to read. :) Under IE6 it works perfectly but with firefox I get nothing.

Any ideas? What info do you want?

nexusone’s picture

the behavior exhibited when viewed in firefox is the same as if the adsense module has been disabled with the check box. If I actually disable it I get the same results in both browsers.

Not sure that that sheds any light or not.

All other options have no effect.

zoon_unit’s picture

just as long as I log out. So it sounds like it might be a theming issue. Does the adsense outline show up where the ads should be? One other thing to check is user rights to see adsense.

leehunter’s picture

Are you using an ad blocker? I know it's a dumb question, but I just spent the morning struggling with the same problem until I realized that I was running the Adblocker Plus extension in FireFox. Changing the AdBlocker settings to allow ads for the site fixed the problem.

Duh.

mrburley’s picture

I'm trying to change my color scheme @ admin/settings/adsense. After making changes and saving the config nothing changes(i keep getting the default "mother earth scheme"). Could someone please tell me what I'm doing wrong. I'm using this php in my block

<?php
if (module_exist("adsense"))
{
 print adsense_display("120x600", 1);
}
?>

the site in question is http://www.mediawakening.com

Thanks

kbahey’s picture

Works fine for me.

See my web site.

I have three color groups defined, one for the left column, one for the content area (the ad links on the top, as well as the one at the bottom), and one for the right column.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

jonsimon’s picture

My site: http://jsimon.net

I created a profile following the instructions, yet do not know within which field I should insert my Adsense id which is ca-pub-420763146073xxxx.

Where do I insert the above?

Should I remove the "ca-pub" and just leave the numbers?

Thanks in advance for any assistance.

dllpkl’s picture

Go to My account -> Edit, then click on the category that you defined for the Google AdSense client ID and enter your Google ID, which is something like "pub-9999999999999", and click Submit.

kalashari’s picture

Is it somehow possible for regular users NOT to have a field "Google AdSense client ID" when they go to edit their profile? It doesn't make sense for regular users to have this field if I am not using "revenue sharing". I mean this field will just confuse users.