How To Add Google Adsense Search Box On A Website

Google Adsense is one of the popular way to make money online by placing ad on the website. To get the approval of Adsense, you need to submit your website for review. Once Google Adsense team approves your website, they provide a JavaScript code which you need to place on a website. From the Adsense dashboard, one can get different sizes of ads like 728*90, 336*280, 320*100, 300*600 to place on a website.

Apart from placing ads, Google Adsense provides Google search engine for a website which helps to earn more Google Adsense revenue. If you are an Adsense publisher, then you should try this method to make money with Adsense. When the user enters a keyword in your website search field, a user will redirect to the search page, where search result will be displayed along with some relevant ads. If a user clicks one of the ad links from search result page, you get a commission for this.

Adsense provides a code for search form and search result which we need to place on appropriate places. When you add JavaScript code of Google search form, default search form layout provided by Google will display on a website.

Google Search Form

You may want to replace default Google search form with the different layout. We will show you how to this in the moment.

Let’s first see step by step guide on integrating Google Search engine on a website.

Add Google Adsense Search Box And Search Result Code

Login to your Adsense account. From your Adsense dashboard, click on My ads->Search->Custom search engines.

Adsense custom search link

Click on the ‘New Custom search engines’ button. On the next page, fill out the form. For ‘What to search’ field, select the second option ‘Only sites I select’ and enter your website URL in the field.

Website URL

Scroll down the page, click on the Search results, select the last option ‘on my website’ and enter the URL of your website search page where you will display the search result.

Website Search Page

Next, hit the Save and get code button. It will open a pop-up window. Copy both Search box code and Search result code.

Search box code will go into the place of your search box. And Search result code will need to place on your search result page.

Replace Adsense Search Box

When we enter a keyword in the Adsense search box and hit submit button, it will redirect to a search page with the parameter ‘?q=YOUR_KEYWORD’.

For instance, if your search result page URL is Then your dynamic URL will become Here ‘wordpress’ is the keyword we want to search for.

If you want to replace default Google Adsense search box, you just need to set action URL of a form to the search page and search field name as ‘q’.

$q = isset($_GET['q']) ? $_GET['q'] : '';
<form class="search-form" method="get" action="">
  <input type="search" name="q" value="<?php echo $q; ?>" />
  <input type="submit" name="search" value="Search" />

That’s it! We hope you got to know about adding Adsense search on a website. If you have any questions or suggestions please leave a comment below.

Related Articles

If you liked this article, then please subscribe to our YouTube Channel for video tutorials.

7 thoughts on “How To Add Google Adsense Search Box On A Website

  1. Hello Bro.
    Please your tutorial was really helpful but the Custom search ads code i was given by google was two.

    1. Search Box
    2. Search result

    How do I implement that? because of the no. displayed but when i tried to search took me to homepage. please try to use your own AdSense account again to look into what I was saying.

Leave a Reply

Your email address will not be published.