How to embed Google Custom Search in Magento

Featured Image

For those of you who love Google Custom Search and would like to use it with the Magento, here is a little how to. Entire embed process is really easy. It all comes down to copy paste-ing few lines of code from Google to Magento. My idea is to create the static block in Magento CMS section and then use the custom CMS page from which I will call this statick block among other HTML content I might wish to throw into the CMS page.

For starters, we need to create Google Custom Search engine. Attached are few screenshots to see how it looks.

Once we have created the necesery search engine, we will copy-paste the embed code into the static block of Magento, lets say we login to Magento, and create static block with identifier “custom-google-search-engine”.

For our last step, we will create a CMS page, giving it SEF URL Identifier “custom-search”, and placing the following {{block type=”cms/block” block_id=”custom-google-search-engine”}} block call into the content area.

That’s it. Now when you visit the url like http://myshop.domain/custom-search you will see the result like shown on photo below.

CC Image credits.


Care to rate this post?


Branko Ajzele

Ex Inchooer

Worked at Inchoo as a Backend Developer/CTO from 2008 to 2013

Other posts from this author

Discussion 12 Comments

Add Comment
  1. sky

    thanks for the post, now I know how easy it is to integrate google custom search into magento.

  2. mark

    this looks great, but do the results come from only the pages google has in its index? for example, my site has over 2000 pages but google only has about 1800 of them in its index due to low link juice, etc on some pages. so now those pages will not be part of the search results. correct me if im wrong? (i hope)

  3. Dan

    @Mark: Google will use the existing pages it has indexed for your website. They offer an “On-Demand” indexing service which provides you with 50 additional urls which will be indexed solely for your search engine. If you want more urls indexed then you need to pay for them. Pricing is available here:

  4. mark

    ok, thats what I thought, pretty disappointing. I think you are much better off using the Magento search. At least with that you know all products will show up, you can taylor the results and you see images of all the items.

  5. This is dissapointing as Google commerce search starets at £19k. I guess you get what you pay for. I would much rather see an SOLR search extension for the community edition. If anybody could point me in the right direction I would be very apreciative.

  6. Thanks branko, it is great tutorial to embed google custom search with magento

  7. Solr for CE maybe would be too heavy solution, but there is Blast Search Lucene extension which does the job properly

  8. Can you place the search box & button in the standard area in the header? Thanks.

  9. Joshua

    I followed all the steps but how do you actually get it to work to place search box & button in the standard area in the header. Do you edit the

  10. I preffer SOLR to Google Site search, but this is only for Enterprise. This is a great solution for Community sites.

  11. This is an awesome feature! Magento’s built in search is a disaster and when you integrate your site with a CMS like WordPress for content marketing, you have to use separate search functions for each. This means you cannot find products from your blog or blog content from your store, which is like having two wheels spinning in opposite directions.

    THIS ELIMINATES ALL OF THAT!!! Their are limitations such as your search is limited by Google’s link index. But honestly if you do not want your page indexed by Google, do you really want someone landing on that page from your search box.

    An excellent follow up post here that I cannot seem to find is how to override the original search box with the new Google CSE search box. It looks like it is time to hit the drawing board again!

  12. Tom

    The search results open in a new tab by default but I found a way to get them to open in the same tab. Here is the code for anyone having the same issue:
    Replace this -


    With this -

    <gcse:search linktarget="_parent"></gcse:search>

Add Your Comment

Please wrap all source codes with [code][/code] tags.