now create a page "search" and add custom search engine script in that page alone.
Now When user search on any page – it navigates to "yourdomain.com/search" and will display the result using Google Custom Search Engine.
In Search form if you enter "nyc" then the page will navigate to "yourdomain.com/search/?q=nyc"
Google Custom Search Engine will get the search query term from the URL
You can add the Default search form in sidebar, footer or so . . using Widgets .. which is less wait, and no need to load google script all the time. and when user search's it will navigate to a page. and in that page alone Google custom search engine script will loads
For most use cases Cloud based Search Engines are best instead on all the things loaded on your server.
Cloud Based Search Engines crawl, index your site on there server and manages. means less load on you server. And its easy to Setup, Maintain.
If you have large traffic website. Instead of using WordPress plugin which index you site on your Web Server use Cloud based Search Engine. ( for setup may need to use plugin, even if it is cloud based search engine )
But there are some Advantages of using WordPress based Search Engines
WordPress plugins Search Engines can know how your website content is, they know the popular products like Woo commerce, easydigitaldownloads. and know how they are structured. So more customize feature, better search result.
For Large Enterprises any thing is fine. Apache solr may be one of the best choose.
It will navigate to show already created Search Engine list.
But if this is the first one to create
Click on "Create a Custom Search Engine" if not, to create a new Search Engine Click on "Add" or click on "New Search Engine" from the left side menu.
Sites to Search
Enter the sites name to search, Can add multiple domain names. can Add domains that even if you are not owned that we.
Individual pages: To search only on some Individual pages – can that page URL e.g. www.example.com/about.html
Entire Site: To Add Entire Site e.g. www.example.com or www.example.com/* but this is not including all sub domains, search on all pages with in www.example.com. To search on Sub pages add like sub.example.com or sub.example.com/*
Entire Domain: to search on entire domain – all webpages that include sub folder, sub domains *.example.com
parts of site / sub folders: www.example.com/blog/ or www.example.com/blog/*
Add the desired language, Language for search engine Messages to display messages
( this is not the language of what your search result is, or what your website content is. )
This is useful to set the language to display search box. like the search box placeholder – text, sort by – text, powered by google custom search – text and similar messages.
Name of the SearchEngine
Give a name to your Custom Search Engine,
If you are using Custom Search Engine public URL ( will check about that in this page ) This name shown at the top of that page just like an heading.
Click on Create to create a Custom Search Engine
on Success you will get the page which provide links to "Get Code", "Public URL", "Control Panel"
At Any Time to get this information
Click on "Edit Search Engine" – from the left menu. And then click on "Setup" – This is Control Panel – for Search Engine
To get the Code – from "Setup" click on "Get Code"
To get, enable, disable the public URL click on "Public URL".
Copy the code and paste it where you like to display the search box, search result.
e.g if you like to add search box in Sidebar, If you are using WordPress and have your Theme provide to add content on Sidebar using Widgets.
Then form wp-admin – Dashboard -> Appearance -> Widgets
Select "Custom HTML" Widget and place that widget where you want – sidebar, footer, header ..
and add the code in that widget and save.
We can arrange things like – Display only Search result or Search box or Seach box at one place and Search result at one place.
To do this – Click on "Look and feel" from the left navigation.
or you change the last line of the code by your self
<gcse:search> – To display Search box, Search Result
<gcse:searchbox>, <gcse:searchresults> – Two Colums – To Display Search box, Search result on two columns with in same page.
<gcse:searchbox-only> – To Display only Search Box
<gcse:searchresults-only> – To Display only Search Result
Instead of manually editing this code, Google will generate this code by changing the settings at "Look and feel"
Customize the color of the link, text, buttons, by navigate to Customize tab, or can change the look and feel using themes.
Add Variations for search terms
e.g. in your website you may use term like "New York City" but user may search for different term like "NYC"
Now if search query is "NYC" Search Engine will show results that are related to "New York City"
Things May need to do
Make Google Custom Search or Google Search Engine know your Website, Web pages. Add your Site at Google Search console and add sitemap. So that Google know what the pages, Content exist on your site and what the result have to display based on the search query.
If you are using Google Analytics – You may be already Added Search Query String in filter "S", CSE default Query String is "q". Make sure you added "q" also. or change the Default Query String. ( in all case you don't need, use this in cases where your URL changes and adds "?q" string before the search query )
At "Statistics and Logs" -> Google Analytics. Select a profile to view Analytics.
Don't Enable – Results Browsing History – just back to previous search result. ( by default disabled )
Tips / Hacks
Instead of adding Google Search Engine Script on all pages,
Just add the custom search box on all pages i.e. create your own search form which is less wait – just an input field, submit button inside form, and When user submit that form make sure to navigate to a page where you added Google Custom Search Engine script. ( have to extend the URL with query string, query text )
Instead of creating a new search form, you can use WordPress / theme default Search form, but one issue here – WordPress search Query String is "s" where default CSE query String is "q". either one have to change to match.
In menu add one more item like "search" and make that link to navigate to page where Google Custom Search Engine Script is added. or add a search bar in menu
What about Google Site Search ( GSE ) ?
GSE vs CSE
Google Site Search ( GSE ), is discontinued
GSE is more Enterprise Edition of Google custom Search, can remove Google Branding, can remove Ads. Its not free. ( any how now its discontinued )