Add Custom Search Engine in your Website using Google Custom Search Engine ( CSE )

Create Custom Search Engine using Google Custom Search Engine ( CSE ) and Add that search engine in your website

Google Custom Search Engine ( CSE ) is a tool to implement search engine on your website, or to a separate URL created by google.

Set your own settings. like which pages to search, What Domains to include, Exclude, Include page, look and feel, Image Search, Speech Input, synonyms keywords, Language and much more

Can add other website to you custom search engine. even that website is not owned by you. No need to verify any domain name, to add in Google Custom Search Engine.

First we will see how to setup Google Custom Search Engine, later we will setup some additional features

And we will check what the other things have to do When google Custom search Engine is Setup, later – Tricks / Hacks ..

add google custom search engine on  website

Create Google Custom Search Engine

Navigate to https://cse.google.com/cse/

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/*

URL Patterns – Google Custom Search

Languages

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

cse - success message

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

cse  - admin - setup

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.

Google Custom Search in Sidebar - using custom HTML Widget

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"

change look and feel - cse

Customize the color of the link, text, buttons, by navigate to Customize tab, or can change the look and feel using themes.

Synonyms

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"

Add synonyms

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 )

or

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.

or

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 )


Alternative to Google Custom Search Engine ( CSE )

Make WordPress Search Form as Google Custom Search Engine – Search box

Add Search box in WordPress Menu

Leave a Comment

Your email address will not be published. Required fields are marked *