Thursday, February 18, 2010

Adding Search Code

"Speaking of search," Stef said, "how do you add a Google search box to a page?"

"It's just as easy as adding the ads," I said. "You go to the Search Settings tab and then the Search code page." I logged back into the AdSense console and went to the Search code page (Figure 8.33). "As you can see, it's similar to the Ad layout code page we just saw."

Figure 8.33. Part of the Search code page.


"There seem to be more options," Stef said.

"There are," I agreed, "because the search box must be customized for your site. You have to tell it what language to use for searching and which Google search engine to use, among other things."

"I thought there was only one Google search engine?" Claude asked.

¿Se habla Google?

Search specific languages and countries in Google from www.google.com/language_tools.


"Google actually runs country-specific search sites like www.google.ca or www.google.fr," I explained. "The search engine technology is the same, but the country-specific search sites rank sites differently."

"The 'Select a search box' section looks pretty complicated," Anita suggested.

"It's not that bad," I assured her. "Basically, you're telling Google how the search box should look and what domains it should search. Besides doing a general Web search, the search box can restrict itself to searching just your own site." I clicked on the Google SiteSearch radio button (Figure 8.34). "See how you can enter a domain name? Let's create a search box to search Claude's site."

Figure 8.34. Creating a site-specific search box.


"All we do now is select a style palette for the results window," I continued. "Basically, this controls the look of the search-results window-the window you get after clicking the search box's Search button. You can tailor the window to match your own site's color scheme and even include a logo. You use the Styles page to manage the style palettes, but we'll just use one of the predefined ones for this example. There. Now you do just like before with the ads-you select the code at the bottom, copy it to the clipboard, and paste it into a Web page."

After copying the code, I used Nvu to create a new page and pasted the code into the page body. After publishing the page to Claude's site, I loaded it into the browser (Figure 8.35).

Figure 8.35. The finished search box.


"There's the search box," I said. "It works immediately." I typed the phrase "voip" into the box and clicked the Search button. A search-results page was displayed (Figure 8.36).

Figure 8.36. The search-results page.


"So I'll make money if someone clicks on those ads?" Claude asked.

"Just like you would with ads on your site, yes," I said. "And the same warning applies: Don't click the ads yourself!"

No comments:

Post a Comment