How to incorporate Google Custom Search engine with Adsense into your WordPress blog.
Jan 25
AdSense is by far the most popular and easy to use advertisement program for new bloggers. With AdSense you earn money when users click on the ads on your website. But the ads are not the only source of revenue for your blog. You can use AdSense for Search to to increase your revenue. But a better alternative to AdSense search is the Google Custom Search Engine. You can customize Google Search Engine to blend with your blog’s theme. You can also specify whether to search entire web or just your own website. It is more customizable than AdSense search and like AdSense for search you can earn money through Custom Search Engine.
To make things little easier I’ve captured screenshots of some of the screens that we will talk about in this tutorial. To view those screenshots click on the thumbnail images in the following sections. For performance issues I did not include the screenshots on this page but provided the links for easy access. Now let’s get started.
-
Create Google Custom Search
- Go to Google Co-op and click on “Create a Custom Search Engine” button. You will need your Google email account to sign in. If you do not have Google account you can sign up for one from this page.
- Log in to your account. You will see ‘Create a Custom Search Engine’ form. (See Fig 1)
- Fill out all the basic fields on the page.
- For the “What do you want to search?” question select “The entire web, but emphasize sites I select.” option. Then add yourblogdomain.com to “Site to search” textbox. See Fig 1.
- Select “Standard Edition”
- Read Terms of Service agreement and click the check box.
- Click the “Next” button
-
Customize Custom Search Engine
- On your Custom Search engine page click on ‘Control Panel’ link.
- Click on ‘Look and feel’.
- Select the style for your search box.
- Click ‘Save Changes’.
- Scroll down to customize your search results.
- Choose same colors for link,text etc. that you use on your website.
- Click ‘Save Changes’.
-
Setup search engine for your blog
- From your ‘Search engine Control panel page’ click on the ‘Code’ link.
- Select ‘Host results on a non-Google site using an: ‘
- Select ‘iframe’
- The most important field on this page is the URL of your page where you want to display the search results. Let’s say that you want to display the results on http://www.Wordpressyoublogdomain.com/search_result. Don’t worry if you don’t have this page yet, we will create the page in a few minutes. Enter the URL in the textbox.
- Choose the position of the ads for your search page. I chose “Display Ads above and below search results”.
- Copy the code from ‘Search box’ code block and paste it to notepad or some other text editor.
- Copy the code from ‘Search result code’ block and paste it to Notepad or some other text editor. We will use these two code segments in your WordPress pages.
-
Monetize your search engine
- From your ‘Search engine Control panel page’ click on the ‘Make Money’ link.
- If you already have an AdSense account, select ‘I already have an AdSense account’. Otherwise select ‘I am a new AdSense user’.
- Fill out all the fields and click ‘Submit’.
- Now your custom search engine is linked to your Adsense account. If the visitor clicks on Ad links on your search results page, the revenue will go to your AdSense account. (Hurray!)
-
Create Search Page
- Log on to your blog as administrator.
- Create a new page. (Click ‘Write’ then ‘Write Page’ links). Click on Fig 6 to see the screenshot.
- In then Page title field enter “Search Results:”. (This text will appear on your page so don’t type any thing silly.)
- Click on the code tab and paste the code from Google’s Search results code text box that we copied earlier [ see Step 3(vii)].
- In the Page_Slug field enter ‘search_result’. This should match the page that you entered the in the URL field on Google’s form.
- Click ‘Publish’.
- From ‘Manage’ tab, go to ‘Pages’ tab and note the id of your result page. (Click Fig 7 for the screenshot)
-
Replace blog search field with Google Search
- For WordPress admin Dashboard click on Presentation tab and then click ‘Theme Editor’.
- Find the code for your search field. Most themes have the code for search field in searchform.php file. If you don’t have that file look under header.php or sidebar.php files.
- Open the file and replace the code related to search form with the code from Google’s ‘Search box’ code that we copied in Step 3(vi).
- Save and close the file.
Now if you visit your site you will see Google search box.
This is great, except for one little problem. Your navigation menu may have the link to your new result page. We do not want that. Let’s fix this.
- Open your header.php and search for ‘wp_list_pages’.
- Add “&exclude=nnn“. (where ‘nnn‘ is the page id we noted in step vii of previous section)
For example I have this line in my header.php file
<?php wp_list_pages(‘depth=1&sort_column=menu_order&title_li=’ . __(”) . ” ); ?>
After the modification the line becomes:
<?php wp_list_pages(‘depth=1&exclude=56&sort_column=menu_order&title_li=’ . __(”) . ” ); ?>
- Save the file.
- If your header.php does not have your navigation links, search for the file that displays these links and add “&exclude” clause as mentioned above.
- Now visit your website. The link to your search page should no longer be in the navigation menu.
First step is to create your Google Custom Search engine.
Congratulations! You now have your very own customized search engine! But we are not done yet. Click “Finish” to go to your “My search engines” page, where you can customize your new search engine.
Now we will customize your search engine.
Now we are ready to setup the search engine for your website.
We are done creating and customizing your custom search engine. The next step is to integrate your custom search engine with your blog.
We are almost done, now the only thing remaining is to replace your blog search field with Google search field.
In this last step we will replace your blog’s search field with the new Google custom search field.
We are all done. Try your new Google search box to see how the result page looks like. You can always go back to Google Custom Search page and modify your search engine.
Hope you enjoyed this tutorial. Let me know if this tutorial was helpful or if you encountered any issues while setting up your custom search engine.
Related posts:
51 Comments (+add yours?)
Leave a Reply



Jan 28, 2008 @ 15:57:22
This is a great tutorial. Thanks a lot.
Jan 29, 2008 @ 04:20:22
Very handy. I was wondering how to do this.
Feb 02, 2008 @ 20:07:22
Sir
Its a great tutorial.
I am using Greentech as a theme. Is this the code (which is under the header.php file) to be replaced with Google search code results?
<form id=”searchform_header” method=”get” action=”">
Which part do I exactly replace?
Ilango
Feb 02, 2008 @ 20:10:43
I am using Greentech and would like to know which is the code I should replace. I found it in the header.php file. Is this the code to be replaced with Goolgle search results code?
<form id=”searchform_header” method=”get” action=”">
Feb 03, 2008 @ 14:33:36
I have followed every step but when I click on the search box I get “page not found”. Could you please help me please?
Feb 03, 2008 @ 17:14:50
@ilango, in your header.php file replace following code
<form id=”searchform_header” method=”get” action=”<?php echo $_SERVER['PHP_SELF']; ?>”><input type=”text” name=”s” id=”s” value=”Search this site…” onfocus=”if (this.value == ‘Search this site…’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘Search this site…’;}” /></form>
with your Google Search code.
Feb 03, 2008 @ 17:22:36
@ilango, if you can send me you google search engine settings I may be able to help you setup your search page. You can email me your settings through Contact us form.
Feb 13, 2008 @ 22:09:58
Great! Thanks for this tip.
Mar 27, 2008 @ 09:00:44
I have created upto 4 steps,I don’t know how to log onto my blog as administrator.Kindly help me sir
May 30, 2008 @ 20:44:47
Thanks! This was great. Made a difficult task a lot easier!
Chad Bordeaux’s last blog post..Dining Out: Salsa’s Mexican Restaurant
Mar 03, 2009 @ 02:55:38
Hello webmaster
I would like to share with you a link to your site
write me here [email protected]
Mar 12, 2009 @ 16:59:57
thank you so much i have been struggling with this for soooo long
Apr 08, 2009 @ 19:14:34
What a useful blog?wow !!!!
Apr 23, 2009 @ 09:10:59
Thank you! This is the only article I read that got our search engine to work! Thank you so much! I read the other ones and they were so confusing.
Cheers!
Apr 27, 2009 @ 01:48:40
Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?
Jul 07, 2009 @ 10:13:24
Hello! can’t find your contact, so I thought I will use this, anyway, we got a private webmaster forum ready to roll in a weeks time, pm me if you’re interested.
Aug 30, 2009 @ 17:38:10
After reading this blog makes me want to start my own
Sep 10, 2009 @ 08:35:28
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
Sep 10, 2009 @ 10:20:45
I love your site.
Love design!!! I just came across your blog and wanted to say that I?ve really enjoyed browsing your blog posts. Sign: ndsam
Sep 11, 2009 @ 09:49:02
Sign: umsun Hello!!! rcuwwymhyw and 8333ssgfhphzye and 7036I love your blog.
I just came across your blog.
Dec 18, 2009 @ 14:03:03
thats perfect info!
Dec 18, 2009 @ 15:08:48
@Search file I am glad you found this article useful.
Dec 19, 2009 @ 21:10:33
Hello everyone. If someone is interested I recommend a SEO links ForOzik.com. System is safe and works well.
Feb 20, 2010 @ 15:34:43
Great blog. Do you know of any relevant post like Top Secrets For Google Adsense Alternatives Have a great day!
May 03, 2010 @ 07:21:10
This is awesome! I found it now. thanks
Jun 14, 2010 @ 03:58:35
This was a Excellent blog post, I will save this post in my Furl account. Have a good day.
Oct 30, 2010 @ 01:04:43
You you should change the page title How to incorporate Google Custom Search engine with Adsense into your WordPress blog. to something more catching for your subject you make. I enjoyed the blog post yet.
Dec 18, 2010 @ 08:51:11
Thank you very much! You just helped me implement my search page. I have another question. How can I remove the posting detail (author, posted when etc.) below the search result? Thank you very much in advance.
Dec 19, 2010 @ 03:51:39
Hello everyone and moderator,
I did the exact steps shown above but the google search bar overlapping my navigator bar.
Can anyone help me with this? I’am thank you very much in advance
May 27, 2011 @ 16:39:10
Thank you very much! I was just Seacrhing this for many days almost a week. Finally i got some ideas.
May 27, 2011 @ 16:41:09
I was thinking of building for my non wordpress site do you have some ideas on that, Request you to please share.
Jul 22, 2011 @ 11:29:31
Thanx a lot… You made the work lot easier
Nov 10, 2011 @ 12:38:20
wish i would have found your tutorial before i went it alone! took me the better part of the day but i managed to get a customized google search box on my site to match the look and feel (by the way, google gives you the css you need to style the form to your liking–as long as you put the !importants in, it works), anyway, my only problem is, i’m self-taught and don’t know anything about apis or whatever, but here’s what i need: the default google search only allows for 1 input field in their form. but i have seen other people’s searches where there are 2 input fields, like if you were searching the white pages, 1 of the fields is reserved for name of the business or place, the field next to it is set up for city, state and zip. if it’s not too complicated, and if you know this one, will you please let me know how to split the form up, rather, add that second field to my search form? thanks sooo much!
Nov 10, 2011 @ 22:50:04
i managed to add another input field, trouble is, it’s not rendering any results on the results page. so…
if ANYONE can walk me through a (SIMPLE) way to add an input field that actually works, i’d be very (VERY) grateful!
thanks in advance!
Jan 14, 2012 @ 14:38:02
Nice blog and very helpful screenshots.
You can actually integrate Google Custom Search in your own Search form of your current theme.
I created a video tutorial on this to make things easier to follow. I am also using it as my search engine in my site. Therefore you can also see it live there.
Thanks again, very helpful indeed.
Jan 18, 2012 @ 05:19:00
Hello,
I’m happy to find this article about google custom search in your website. I think you might be interested to use our search plugin.
So, I’m inviting you to try our plugin searchGBY. It is a plugin for the major browsers that helps you in your search by combining all results from the major search engines into one.
If you have questions about our plugin, don’t hesitate to contact me.
Leo