Cashing In with Google Ads on Your SiteYou probably didn't realize it but you can make money using JavaScript. And I'm not talking about your becoming a contract JavaScript programmer and hiring out your services. I'm talking about using your web pages to attract visitors, and then making money off of their responding to ads placed on your pages. Don't worry, I'm not going to show you how to create annoying pop-ups or anything like that. Google, the popular search engine, offers a free service called AdSense that allows you to place content-driven Google ads on your pages. You then earn commissions on these ads when people click them. Yes, it really is as easy as that. The difficult part of making money off of ads is getting enough traffic to your site so that people will respond to ads. Although Google can't do a whole lot to help increase your web site traffic, AdSense does go a long way toward improving ad response rates by intelligently placing ads on your pages based on the content in the pages. In other words, you're really giving Google space on your page to insert whatever ad they best see fit. In my experience, Google does a surprisingly good job of matching up content with page content.
If you're curious to see Google AdSense in action, check out Figure 17.9, which shows ads on my personal web page that are driven entirely by the subject of the page (BlackBerry devices). Figure 17.9. My personal web page uses Google AdSense to display content-driven ads.The page in the figure is about a BlackBerry book that I wrote, and not surprisingly, the resulting ads displayed by Google all relate to BlackBerry devices. By the way, the American Red Cross ad is not an AdSense adI created it myself to help encourage people to contribute to the Red Cross's disaster relief efforts. To get started using Google AdSense, you'll first need to create a Google account. This is entirely free, and mainly just requires you to provide an email address and agree to Google's usage terms. To sign up for a Google account and start using AdSense, visit https://www.google.com/adsense/, and click the Click Here to Apply button. You'll receive a unique client ID that is used to connect your pages to AdSense so that you can earn commissions. After creating an account and logging in, you can immediately start creating ads. What makes AdSense so easy to use is that Google automatically generates JavaScript code that you can paste directly into your web pages. The main AdSense code-generation tool is called AdSense for Content, and it is accessible online at https://www.google.com/adsense/code. AdSense supports several kinds of ads, including text ads, image ads, and ads that can use either text or images. There are also various ad sizes from which you can choose. Figure 17.10 shows a partial sampling of some of the ad sizes and layouts you can use. You can view this page from within the Google AdSense for Content page by clicking the View Samples link. Figure 17.10. Google AdSense supports a wide variety of ad types and sizes.In addition to selecting the ad type and size, you can also choose from one of several palettes. After specifying all the ad details, you'll eventually arrive at the bottom of the AdSense for Content page, which takes all of your selections and generates JavaScript code for the ad. This code will automatically include your Google client ID, so you don't have to worry about entering it. If you click in the edit box containing the JavaScript code, it will automatically highlight so that you can copy it (see Figure 17.11). Right-click the code and select Copy, or select Edit, Copy from the main browser menu. Figure 17.11. Google AdSense automatically generates ready-to-use JavaScript code for the ad that you create.
You now have some JavaScript code ready to place in your own web pages. Just paste the code into the body of a page, as shown in Listing 17.6. Be sure to copy and paste the code without modifying any of it. Listing 17.6. Google AdSense JavaScript Code Should Be Copied into the Body of a Web Page<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Google Ads</title> </head> <body> <h1>Oodles of Google Ads</h1> <p> Google AdSense uses the content of your Web page to determine what ads to place on the page. If it can't find a suitable ad to match your content, it will display a public service ad. </p> <script type="text/javascript"><!-- google_ad_client = "pub-239211407"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "000000"; google_color_bg = "F0F0F0"; google_color_link = "0000FF"; google_color_url = "008000"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </body> </html> The page in Listing 17.6 is shown in Figure 17.12, complete with a public service Google AdSense ad. Figure 17.12. Google AdSense automatically displays ads on your pages.In this example, there isn't enough content on the page for AdSense to match up with an ad, so it opted to show a public service ad. This can happen if a page is light on content or if the content is very obscure and no ads exist for that particular content.
|