Reputation: 5469
I would like to use a Google Custom Search Engine on my website.
With Google's default implementation, you have to put Javascript on each page that has the search box. For privacy reasons, I would like to load that Javascript only for those users who actually use the search engine.
I would like to have a generic
<form>
<input type=text>
<sinput type=submit>
</form>
on each page and then submit to another page where the Google code gets loaded and executed without the user having to click a 2nd time.
I could easily place the Google code on a page and just have a link to the search page on every page, but I can't get it to work with a search box on very page and no 2nd click from the user.
Upvotes: 1
Views: 236
Reputation: 4484
There is a manual Tutorial: How to dramatically improve search by implementing Google Custom Search that sends the search request to Google on after the repondent has used the search feature.
By and large, it goes like this: Add a page to Q2A with some JavaScript to send the search request, and then modify one Q2A file to send the (default) search to the new page instead the original search page.
Upvotes: 0
Reputation: 5469
You can configure the Goolge custom search engine to only display search results. Then you only have to include the Google script on the results page, eg. results.html.
On other pages you can place a generic search form with the results page as action:
<form action="/results.html" method="GET">
<input name="q" type="text">
<input value="Search" type="submit">
</form>
In this configuration data is only transmitted to Google if the visitor to your site actually uses the search function.
Upvotes: 2