Internal searcing put into google analytics - lucene

I am in need of implementing google analytics on a site where i have my own search functionality, and i would like to have the ability to tell analytics what the users are searching in the internal seaching, so i can catch the search terms and other interesting stuff.
So the buttom line is that when the users are searching with the internal search, this should be shown inside google analytics, which terms they used, which page them came to and so on.. All the stuff that google's own search implements.
Others must have done this, but i can't find the right information.
thanks in advance!

As Eike Pierstorff mentioned in his comment, within the interface you can set GA to look for a parameter in the URL. So if your site search already passes the search term as a query string parameter, just set GA to look for that parameter and you should be good to go.
If your site search does not push the search term to a query string parameter (e.g. it's AJAX based or simply doesn't do it), you can push it to the _trackPageview call.
Example:
// do what you have to do to populate this variable with the search term
var searchTerm='search term here';
var pageName = location.pathname+location.search;
pageName += (location.search) ? '&' : '?';
pageName += 'q='+searchTerm;
_gaq.push(['_trackPageview', pageName])
Then in the GA interface, set GA to look for the "q" parameter.

A simple way to do it is to send a custom Event whenever your search button is pressed or when the results are shown.
Add the search string as the Event Label.
You will then see the website searches on the Behavior->Events section.

Related

custom google search autosuggestion

I have created a custom google search application for my website.
Below is the url
https://www.google.com/cse/
to create application.
Under the Auto complete section i have enabled autocomplete,but still it dont suggest me the options when i start typing on search box.
It suggest me only the keywords that We define under custom autocompletions.
SO my question is : Do we need to provide all the custom keywords that we want to autocomplete in search box or google just creates its own autosuggestion from the website ?
It creates autosuggestions from the website, but it may take few days to collect all data. It also takes into account user's queries on your website.
As previous answer suggests, autocomplete can take a few days to begin working. In addition you must specify one or more specific sites / pages to which to restrict the custom search engine. On occasion, you may also have to specify that the CSE only search those site(s) / page(s) instead of simply emphasizing them in the results.

Make google custom search location-aware

When I search for "football images" on google.co.uk, it knows that I mean the sport that elsewhere might be called "soccer". If I do the same search on google.com, I get American Football.
I'm using the custom search API - how can I tell it that I'm in the UK and would like results relevant to here?
You can limit your engine to operate on sites from a particular country via "cr" param, e.g. in Custom Element it looks like this:
<gcse:search cr="gb"></gcse:search>
Google knows some synonyms on the web, but if your particular use case is not correctly recognized you can add it in Control Panel in Search Features > Synonyms
More on synonyms:
Sorry, I ended up answering this myself. I couldn't get any of the instructions under the custom search API itself to work (although the answer offered above was also mentioned there, but this just made my CSE Context XML apparently invalid), but you can make requests to a custom search engine by using the instructions here https://developers.google.com/custom-search/json-api/v1/using_rest and an API key.
This is how I did it;
<gcse:search cr="countryUK"></gcse:search>
You can even return results in a specific language, code shown below returns results only in french;
<gcse:search lr = "lang_fr"></gcse:search>
This is the reference for Google Custom Search Element Control API: https://developers.google.com/custom-search/docs/element?hl=en
Try to set the 'gl' parameter to the country you want.
For details, look into CSE:list

Google autocomplete api for my site

Is it possible for google autocomplete api to specify to return results only for my site not for all sites? I see that there is param ds, but only purpose for that is to search in youtube. So how can I get autocomplete or maybe related or suggested search words only for single site?
I needed the very same thing and so far the only way I found to get this working is to create a custom search engine and then add it as a parameter to the autocomplete call:
http://clients1.google.com/complete/search?client=partner&gs_ri=partner&partnerid={0}&ds=cse
Where {0} is your custom search id
Certain features such as returning the results as XML don't work if you use the partner id but at least all the autocomplete results will be from your site.
You can also have multiple search engines and use different ones in different textboxes. Results are just a json string you parse.
Good luck

Google Custom Search Query Parameters and Category Parameters

So I'm trying to set the query parameters and category parameters for google custom search. Here is an example search results page url:
http://www.whiterootmedia.com/search_results/index.html?q=my%20search%20phrase
So it looks like the default query parameter is q so I put q in the box when setting up the analytics portion for my google custom search engine. Is this ok? I read it wasn't ok to use q but to instead use query? And why does it matter?
Also should I set a category parameter that looks to be optional.
Thanks,
Dusty
The Google Search API just uses q. AFAIK the API doesn't have a query parameter. Check out the custom search API documentation.
Not sure what you mean by the 'category' parameter. Haven't come across that one before.
HTML:
<gcse:search gname='google1'></gcse:search>
Javascript:
window.google.search.cse.element.getElement("google1").execute("hello world");
But you need to wait for the Google script to load before launching the javascript.
If you use searchresults-only instead of search, you also need to enable the correct layout in the CSE Control Pannel: https://www.google.com/cse/
You can hit the following: https://cse.google.com/cse?as_q=your_query_string%20must_be_urlencoded&client=google-csbe&cx=full_cse_id_goes_here:including_the_bit_after_the_colon
So a direct answer to your question - the query parameter key is 'as_q'.

how to correct spelling mistakes in Google custom API

I am using Google's custom search API, I make an HTTP request to a URL that looks like this:
https://www.googleapis.com/customsearch/v1?key=<my-key>&cref=&num=10&q=how+can+i+do+htis
if you search for "how can i do htis" on Google you are told "Showing results for how can i do this", and give you some results (call them result set A)
but if you use the API to search for the misspelled string, you get different results than those of A... Searching with a correctly spelled string gives you result A, which matches the ordinary search service on Google
Is there a way to search directly using the suggested string? I want to use the API I can't afford implementing a spell checker myself that can also correct people names and everything
I think what you want to do is possible using the spelling suggestions of Google. This is part of the xml-results returned by your query.
See API here.