Adding Google Adsense Module in Drupal
1. In order to use Google Adsense, you will need to create your Adsense account BEFORE adding to Drupal. You can create an account by going to https://www.google.com/adsense, clicking the Sign up now button and following the instructions for creating an account.
Quick Warning: Try to avoid using the back button in your browser, because when you do you tend to lose any of your changes and need to start over. This happened to me more times than I’d like to admit!
2. Once you have created your account, log-in and click the AdSense Setup tab. On the page that appears, click the AdSense for Content link. The page that appears wants you to choose what type of ad to use. The Ad unit button is selected by default and that is what we want. In the drop down box next to Ad unit, you can choose what type of ads. Text ads only will create standard written advertisements, Image ads only will create more flashy ads that may blink or jump out at you, and Text and image ads (default) will obviously have both. It is completely up to you what you would like to do. Text only ads are less likely to grab the attention of your visitors, but they do not detract much from your site and are less of an annoyance. Image only ads certainly get people’s attention, but also may annoy your visitors. I chose the text only ads because I feel that people get really turned off by flashy ads since you are making it perfectly clear that you are trying to make money off your site. However, you generally only make money when people click on the ads, so it maybe it is a good option. I wouldn’t dwell on it to much since you can change it at any time. Once you have decided, click the Continue button.
3. On the next page, you can define several different formats for your site. Let’s go through each category individually.
Format: you will choose the size and structure of your ads. First, click the link titled Ad Formats. This will bring up a screen that shows what each ad format looks like. Before you choose the format from the drop down menu, click the Ad Formats link in the description of Format so that you can actually see what the ads will look like. Take a look at each of the options and pick the one that looks the best to you.
Whatever you choose, make sure that it fits correctly into your screen. Their sizes are measured in tenths of an inch, so their 180 x 150 small rectangle option measures 1.8 inches by 1.5 inches. Therefore, you can measure the sizes by using a ruler directly on your monitor.
I am not a big fan of the horizontal options in general, but other than that I think it is really up to personal taste. I chose the 160 x 600 Wide Skyscraper format for buildyourownstory.com. Be aware: this is the one option that you cannot change later. If you change your mind about the size later, you will need to create a new ad type. After you have gone through this process once, it won’t take you long at all to create another ad type, but just keep it in mind.
Once you have made your choice, you can close the screen you just opened. Back in the original page, select your format from the dropdown menu.
Colors: there are several options to you on the right side of the screen. You can choose from a few different Palettes through the dropdown box and you can change any of the other colors by clicking on the little box next to it. As you make different choices, the sample ad on the left will change with it. Clicking the Tips link in the description of Colors can also give you an idea of which colors will attract the most interest for your site.
Fonts and Corner Styles: you can choose the font of the text in your ads from the drop down box. As with the colors, any changes you make will show up in the Sample ad. It doesn’t make much difference which one you choose, so just choose what looks the best to you or just leave it with the default choice.
More Options: you can choose what to do if targeted ads are not available. Targeted ads are ads “targeting” the visitors of your site. The beauty of AdSense is that Google caters the ads to the content of your site so, for example, if you have a site about clothes, Google is likely to use ads of different clothing and apparel stores. However, if no targeted ads are available for whatever reason (Google can’t figure out what type of site you have or maybe none of the suitable companies to your site don’t want ads at the moment), by default Google chooses the “show public service ads option,” which means they will put up any random advertisement. You can also choose the “Show non-Google ads from another URL” option, where you can create your own image to use in the ad space. Or, you can choose to fill the space will a solid color so that visitors don’t see any ads. I just kept the default option, but you can do what you want. Click the Continue button when you are finished.
4. In the next page, you need to choose which sites in which you would like to use the ad format you just created. To do that, first click the Add new channel link towards the bottom of the page, and in the box that appears, enter your site, leaving out the http://www. portion (i.e. buildyourownstory.com). Then click the Continue button.
5. In the next page, you will choose the description for your AdSense unit. It can be anything you like, but choose a title that makes it easy for you to know what type of format you used. For example, I called mine “160×600, Wide Skyscraper.” Then click Submit and Get Code and you are finished with this process! Before leaving, on the next page, copy the entire code in the Your AdSense unit code box. We will use it in a second.
6. Now that you created your account and format for Google AdSense, you can add it into your Drupal site, which is not as hard as you might think.
There are a couple things you need to do before putting this into Drupal. First you need to download the AdSense module from the following link http://drupal.org/project/modules?solrsort=title_sort%20asc&text=adsense or by going to the drupal homepage and clicking the Download tab, then the Modules link, then entering “adsense” into the Search modules box (not the Search box at the very top of the page). You can download the file to wherever you want and then upload the files to your host server. For instructions on how to do that, see the Downloading Modules page. Once you have done that, the Adsense module should have been added to your site. Go to the Sitebuilding-Modules page and you should see that AdSense has its own dropdown section and several items within it. Check the boxes next to all items that don’t have “(old)” at the end of them, scroll to the bottom of the page, and click the Save Configuration button.
Now, you need to download another module titled pathauto, which will allow you to add php code as an input format for AdSense (I will explain in a minute). You can find it at the following path http://drupal.org/project/pathauto or by going to the drupal homepage and clicking the Download tab, then the Modules link, then entering “pathauto” into the Search modules box (not the Search box at the very top of the page), then look until you find the correct download. Extract it following the same process as before. As with AdSense, this module should appear immediately within Drupal. Go to Sitebuilding-Modules, and look for Pathauto in the Other section and click the box next to it.
Now, go to Site Building-Blocks, and click the Add blocks link at the top of the screen. On the next page, in the Block description field enter something like Google Ads or Google Adsense. The Block title field is optional. Whatever you type in this field will appear above the Google Ads box. Since the Google Ads box already has Ads by Google at the top, I chose not to give a title. If you decide to enter something, I believe Drupal will give you an error message if you use the same phrase for both Block description and Block title, but I think you can do it anyway. If not, just provide a similar phrase for each that is slightly different. Next, paste the code you just copied into the Block Body field. Click the Input format link and choose the PHP code button. This button appears only if you have the pathauto module enabled. If you do not see this button, retrace your steps for downloading pathauto.
You can leave the rest of the page blank. Now, go back to your homepage and you should now see your Drupal ads!
If you found this article to be helpful, please consider making a donation.

