Post Pic

How To Install Google Custom Search On Your Wordpress Site

The easy way to monetise searches on your site

Most sites these days, certainly most Word press themes, will have a search function built in so that the reader can search for a particular page or post within that site. However, a lot of these default search functions can be a bit limited in their accuracy. Adding a Google Custom Search to your site will allow the reader to search your site accurately and allow you to serve Google ads around those results. Everyone’s a winner!

Installing the Custom Search doesn’t take long but there are a couple of slightly techy elements to it so take your time!

Firstly, sign in to your Google Account. if you don’t have one yet you can go here and sign up. It’s quick and free and you’ll have one of the best free email services on the internet! Once you’ve done that, go to https://www.google.com/adsense/adsense-products and click on AdSense for Search.

You’ll then have the option to specify which site you want to search through. This is great if you have more than one site because you can enable a search across all of them and thereby generate traffic to them from any search results. You can also specify individual pages form sites in case you don’t want some pages to be searched.

In the case of this site, You would simply type in http://the reallyusefulblog.com which would return search results from the whole site. After that, you should select some keywords relevant to your site(s) which will help decide what ads to display with your search results. For example, really useful blog, free advertising, tips for marketing beginners etc

Select which country you want the results to come from, decide if you want adult content to appear in the results and click next.

You’ll then be taken to a page which allows you to change the appearance of the search box so you can play around with this to see what works for you. I would suggest reducing the text box length as the default size is fairly big.

Next, you can choose whether or not to have the results displayed within your own site or in a new window. Personally, I want mine displayed on my site, since anyone searching would probably be looking for something on my site anyway! Either way, you’re going to need to create a page on your site where you want the results displayed so stop what you’re doing with Google and come back to your Wordpress Admin.

Go to Pages > Add New, then call your page something like “Search Results” and save it as a draft. You’ll then notice that the URL for the page will be displayed under the title and it will say something like “http://thereallyusefulblog.com/search-results”. Copy everything between the ” ” and paste this URL in the box where it says “Enter the URL where search results will be displayed” in your Google AdSense Setup. Now you can play around with the size of the results area and colour schemes to suit your site. Don’t worry too much about the size just now as you can always come back and change it later. When you’re done, click continue, agree to the T&Cs, give your new search engine a name and click on “Get Code”. Stop there and come back to Wordpress Admin.

Now this is the cool bit. Click on Plugins > Add New, and type in “Exclude Pages From Navigation” without the quotes. Install the plugin, activate it, then go back your saved Search Results Draft page. At the bottom right of the screen you should see a wee check box that says Include This Page In User Menus. Uncheck it and click Publish. You now have a hidden page that won’t be visible to anyone visiting your site but will appear when they conduct a search. Why is this a good idea? Because otherwise you’d just have a page with nothing on it that will probably make people leave your site if they see it.

Now, this is where it gets a bit sticky so pay attention! In Wordpress Admin, go to Appearance > Editor and open Page.php. Copy and paste the entire code you can see into notepad or another text editor. Just keep that safe for the time being in case you make any mistakes. Now, in Appearance > Editor > Page.php look for this code:

<?php the_content('<p>Read the rest of this page &raquo;</p>'); ?>

Found it? OK, then go back to Google AdSense and copy the code you can see for “Search Results Code” and paste it right underneath the code above. Now copy the following code:

<?php
/*
Template Name: Google Search Result
*/
?>

And paste it the very top of the Page.php code. This code will register a new page template in Wordpress. Copy and paste the entire code and paste it to a new notepad file. Save it as “GoogleSearchResults.php” without the quotes then upload this file to your /public_html/wp-content/themes/whatever your theme is called directory. The best way to do this is to use a free program such as FireFTP but if you’re uncertain about how to go about it then your Domain Hosting Provider should be able to help.

Once that’s done, go back to Wordpress and navigate back to your saved “Search Results” Draft Page. Click on Edit and have a look at the right hand side of the page. You’ll be able to change the page template to “GoogleSearchResults” which is what you saved earlier. Publish this page again.

We’re almost done. If you don’t have one already, go to Plugins > Add New and type in Advanced Text Widget, Install the plugin, activate it, then navigate to Appearance > Widgets. You’ll be able to see the Advanced text Widget there. Simply drag and drop the widget to where you want your search box to appear, then copy and paste the code you can see in Google AdSense for “Search Box Code”, save it and close.

Now, if you’ve managed to do all that properly ( and I know there was lot!), you should be able to test your shiny new custom search engine by simply typing in a word or phrase. If you find that the search results break the frame or borders of your page, then just go back to Google AdSense and reduce the results page width, try again and adjust as necessary.

If your ads don’t appear right away then don’t worry, they can take a wee while. That’s it, you’re done. You now have a Google Custom Search Engine on your site and you can start making money every time someone does a search!

Related Posts

Popular Posts


blog comments powered by Disqus
Upvote this page for
"Really Useful Blog"
at a new search engine
 

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

The Really Useful Blog is using WP-Gravatar

Content Protected Using Blog Protector By: PcDrome.
{