Skip navigation.
Home
Free Online Computer Help Community

Question: How can I easily add Google Adsense into my Drupal 6x or Drupal 7x CMS Site? Ez-Tutorial/Instructions

Computer Help's picture

Question:

How can I get Google Adsense ad's to work with Drupal 6x? None of the instructions on the web or forums seem to work right or they don't show up period. These instructions seem way to hard to begin with anyways.

This tutorial works 100% for Drupal Versions: 6.0, 6.1, 6.2, 6.3, 6.4 6.5 6.6and Drupal 7.0!.

Introduction:

I myself run Drupal 6x and every time Drupal is upgraded, I do so at the first chance I get. As a web host technician I see clients get hacked left and right due to failure of upgrading their CMS or the lack of effort used to try to upgrade. This comes with a few downfalls as everyone knows. Installing customized themes and older modules simply don't work when installed, or stop working all together. I recently ran into this when trying to find a clean way of installing Google Adsense ad's like you see to the left of this web page. I followed every tutorial and instructions posted on the drupal.org forums and various blog pages around the web. Finally, I was able to do it on accident while following instructions that were similar. I will share them with you below.

Note: Please read all of the instructions before assuming these won't work.

Very easy simple steps that any Drupal 6x user can use to get Google Adsense to work right!

Instructions:

1.) Login as the administrator account on your website and click on [Administer]. I will give these instructions using the installed theme "Bluemarine".
2.) Now after clicking [Administer] look on the right page at the top. You'll see two tabs called "By Task" and "By Module". Go ahead and click "By Module" Click Here for Screenshot.
3.) After the new page loads, look for the category [Block] and click on "Blocks" under the category. Click Here for Screenshot.
4.) Once the new page loads click the "Add Block" tab or button so you can create a new block for your CMS site. Click Here for Screenshot.
5.) After this page loads fill out the following forms as instructed.
Block description: * Google Adsense Block

Block title: Sponsored Links

Block body:
Insert the Google Adsense Java Code that is populated for you after creating how you want Google Adsense to work on your page. http://www.google.com/adsense will take you to the login for this.
Click on "Input Format" to display it's options if necessary. This is the most important part. Despite how your running your site, check/enable PHP code "* You may post PHP code. You should include <?php ?> tags." DO NOT CHOOSE Filter or Full HTML options!

Custom visibility settings: Users cannot control whether or not they see this block.

Show block for specific roles: Don't enable either of these options.

Show block on specific pages: Don't choose a option. If you have to, choose: Show on every page except the listed pages. and leave Pages: Blank Unless you know what your doing.

Screenshot #1 Screenshot #2

6.) Click on [Save Block]
7.) Now move your new block to your left or right sidebar. You can move this anywhere else, but you might want to test in these positions on your website. Click Here for Screenshot.

Wellah, go to your web page and refresh. You might have to clear your browser cache but I can assure you that it should be working if you followed these instructions in detail. I will post screen shots as soon as I get some spare time.

Comments and suggestions are always welcome with Guest privileges.


Story / Related Content

I have enabled the Google Adsense Module and it displays fine on my right hand side bar.

However I need to resolve the following:

1. I would like to have Google Ad's automatically embedded into the end portion of a new STORY

2. The content that currently shows on the right hand side bar in no way is related to the content that is being displayed on the page. For example - if I had a story about XBOX 360 and it's games I would expect the displayed ads to be related to that .... but they display as generic ad's for Content Management Systems.

It seems as though it is displaying ads that are related to Drupal / CMS packages as opposed to the content on the site. It's as if the content of the block that contains the adsense module doesn't even read the content on the site.

This holds true as well if I put it in the header or footer.

Computer Help's picture

Related for me

I don't know why your ads wouldn't be relevant to the article on your page. While I haven't found a module that works well with Drupal 6x for injecting the ads into the content, I was able to confirm that my ads are reflecting the same category as my articles.

I just went to a VoIP, Magic Jack, and nVidia bug articles and all my adsense links were related to the article. A few them were way off in a strange way. What I mean by this is about 4 text links show up for adsense for me. 1 out of 4 would be off topic slightly, but that was it.

I don't know if your trying to be more define in which ads are displaying or not. You can browse some of the articles I have and see how well they are related. Maybe this has to do with another module you might be running conflicting with this?

Close ..

When I actually go into the article ( ie: click on the headline for the story ) it displays a ad's that more on par with the content of the story.

However, the real problem is when the main (front) page is up.

The right side bar that contains the ad's do not appear in anyway to reflect the content on the home page. The content is obviously the snippets of all of the stories.

Instead of being related to the content in the snippets of the stories it instead just displays Drupal or CMS adverts. Once in a while it will display an add about a chat / dating site and I believe this to be because of the use of the word "chat" in my site name/title.

Computer Help's picture

Correct

Yes, it's designed to do just that. There is so much content and such a wide range of subjects how can it understand what ads it's supposed to display? It does the best that it can with displaying the correct ads on your feed page/main page with the teasers. You may want to set some channels in your adsense account to overcome this. As I have not set these up personally, I can't give any advice on how these are done. Checking with the readme's and contacting adsense support would be beneficial.

Sometimes on my page the same thing happens to me, I'll often get some charity links and things of that sort. I'm not to worried about it as most of my traffic comes in from SE right to my blogs. The adsense traffic that I do get usually comes from people who are looking for something they can't find, usually in full article of the issue their trying to resolve. I would say about 2% of my clicks come from the main page. This might be a different situation for yourself.

Version 6.1 provided by godaddy doesn't even have those options

You have only two option under input format...Filtered HTML and FULL HTML. The fix you speak of doesn't even exist.

Computer Help's picture

Yes, it does.

It does exist. I upgraded to 6.4 recently, so I went and checked for myself. All (3) options under INPUT FORMAT do exist. If it doesn't for you then your trying to do this under a custom theme, or your not using DRUPAL. You are welcome to post a screen shot in the forums if you need further assistance.

I just installed drupal 6.4

I just installed drupal 6.4 and the PHP code doesn't exists only filtered html and full html exist both which don't work. I had to go into administrator->site configuration->input formats and create a new format with no filters selected to get it to work.

Computer Help's picture

It should be on Drupal 6.4

Hello,

It's there I can assure you, or you have install Drupal from elsewhere and not directly from their website {drupal.org), or you are using a theme that is not allowing it to come through.

1.) Make sure your administration theme is set to a default theme. Don't be using your customized theme to do Administration. It's a very *bad* habit to get into if your not advanced with Drupal.

2.) If your following the guide lines above, please take a look at this screen shot in my instructions:

http://www.computerquestionhelp.com/outsideimages/drupal6_adsense_input_...

You will notice that clicking on [Input Format] may be necessary in order to get that option working. If it's still not there you need to revert back to (1.) or submit a thread in the Drupal forums and ask why that filter option is not showing up for you. I don't believe creating one is going to help you in this instance.

If you have new information to provide me on this, let me know and I'll see what I can do for you.

Regards,

Enable PHP filter module

PHP filter module needs to be enabled in order to use PHP code input format.

Computer Help's picture

That's correct but this is

That's correct but this is enabled by default in a standard Drupal installation. This is why I didn't bring it up along with many other things that are required and setup by default with Drupal. But that's a good point I guess for someone who might be having trouble.

I'm going to be writing a new article soon on a very easy step by step tutorial for setting up Adsense so it can be injected into all newer versions of Adsense. In about 1-2 weeks I would suspect I should have it posted on the main web page.

I was wrong it did work-Thank you-

Wow-thank you for your help on this tough issue

Error message generated

Hi,

I followed your instructions for the latest Drupal 6.3 and get the following error MSG:

Parse error: syntax error, unexpected '<' in /hermes/web07/b1087/pow.username/htdocs/drupal/includes/common.inc(1537) : eval()'d code on line 2

I get no AdSense list.

Thanks for any help.

Computer Help's picture

Hello Perry,

First question. Does the error go away when you disable the custom block you made for adsense?

Second question. Can you fill out the form using my instructions as before and taking a screen shot?

You can send me a private message on the forums if you want for additional ways to contact me live. I help walk you through it on my days off work Tuesday - Thursday.

Cpu Help Admin

It works!

I redid your steps and it now works - I swear I did that before.

Sorry to waste your time but I'm up and running just fine.

Thanks for the help.