Google-Analytics API to track Site Search? - search

So there's this nifty _trackPageview() api method on a tracker object, but is there a corresponding method that can be used to manually track a search? In other words, _trackPageview() reports to GA that a user hit a page. I want something like _trackSearch("terms") that would report to GA that a user searched for something.

Though not exactly what I was looking for, it seems that one can generate virtual page views to track search results programatically.
Suppose that you've set up a Site Search parameter called "q", so that when a URI is tracked that contains q=these+are+some+terms, GA will mark it as a search hit. One can use the _trackPageview() method to generate virtual search hits like so:
pageTracker._trackPageview('/custom/search?q=These+are+some+terms')

I pass search parameters by GET, so the URL for a search on "TEST" is
http://www.example.com/search?q=TEST
Selecting Content -> Site Search from my analytics account gives me a list of all keywords searched.
To learn more, check the documentation, especially the How do I set up Site Search for my profile? page.

Related

Sphinx "reverse" search

We have a website where users put up ads for stuff they want to sell, with parameters such as price, location, title and description. These can then be searched for using sphinx and allowing users to specify min- and maxprice, a location with a searchradius (using google maps) etc. Users can choose to save these searches and get emails when new ads appear that fit their search. Herein lies the problem: We want to perform a reverse search every time an ad is posted. With the price, location, title and description as parameters we want to search through all the saved "searches" and get the ones that would have found the ad. The min- and maxprice should just be performed in a query i suppose, and some Quorom syntax to get all ads with at least 2 or mby just 1 occurance in the title/description. Our problem lies mostly in the geo-search. How do we find all searches where the "search-circles" would include our newly posted location without performing a search for every saved search?
That is the main-question, any comment on our suggested solution to the other problems is also very welcome. Thank you in advance / Jenny
The standard 'geo-search' support on sphinx should work just as well on a Prospective Index, as a normal retrospective search.
Having built a sphinx 'index' of all the saved searches...
And you run a query using the 'ad' as the search query:- rather than the 'filter' using a fixed radius, you just use the radius from the attribute (ie the radius stored on the particular query) - if using the API cant use setFilterRange directly, need to use setSelect, to make a new virtual attribute.
$cl->setSelect("*,IF(#geodist<radius,1,0) as myfilter");
$cl->setFilter('myfilter',array(1));
(and yes, the min/maxprice can just be done with normal filters too - just inverting the logic to that you would use in a retrospective search)
... the complication is in the 'full-text' query, if the saved search is anything more than a single keyword, but you appear to have already figured out that part.

How to get keyword type (Organic or Paid) from Google Analytics Reporting API

I am using Google Analytics Core Reporting API. I have a little confusion that I want to discuss.
First I want to get keyword which User has searched to reach on my site. I have used ga:keyword. I have also seen one other dimension which is ga:searchKeyword. Which one of these will give me desire result?
Second I want to get keyword type is it organic or paid? If I will use ga:medium then will it give me type of searched keyword?
BTY using following function to get results
private function getResults(&$analytics, $profileId,$data) {
$optParams = array(
'dimensions' => 'ga:visitCount,ga:browser,ga:fullReferrer,ga:keyword,ga:country,ga:campaign,ga:medium'
);
return $analytics->data_ga->get(
'ga:' . $profileId, $data['start_date'], $data['end_date'], 'ga:visits',$optParams);
}
Please guide me.
Best Regards,
ga:searchKeyword is only for keywords from your internal site search. ga:keyword and ga:medium will give the desired result.
According to the documentation, ga:keyword tracks:
When using manual campaign tracking, the value of the utm_term campaign tracking parameter. When using AdWords autotagging or if a visitor used organic search to reach your property, the keywords used by visitors to reach your property. Otherwise the value is (not set).
ga:medium can be used to tell organic search and paid clicks apart. It tracks:
The type of referrals to your property. When using manual campaign tracking, the value of the utm_medium campaign tracking parameter. When using AdWords autotagging, the value is ppc. If the user comes from a search engine detected by Google Analytics, the value is organic. If the referrer is not a search engine, the value is referral. If the visitor came directly to the property, and document.referrer is empty, the value is (none).

Search Box Webpart - Default to a custom search scope

I've two search box webparts in a same page targeted to different audiences. I want to configure the search boxes to seach a specific search scopes which I've created.
Any ideas how to do that?
Typically the search box points to the page with the desired search results web part. That is a problem if you want both search boxes to point to the same page. You might look at using web part connections and have 2 pairs of web parts - search box and results "A" and "B" where the "A" pair uses a connection to define the link. Then the result part "A" would select the desired scope and/or audience and so forth.
I've created a custom search control which redirects to the search page. I've passed all the necessary details such as keyword, scope etc in the URL.

Sharepoint 2010 Search - Auto add property to QueryString

Have a bit of a difficult question which as far as I can see, no one has really managed to fix yet.
Here's the scenario. Sharepoint 2010 EnterPrise Search Centre.
I've created a custom Search Results Page. I want people who type any word in the Search box to only display results where the Value provided by the user matches with a specific Managed Search Property.
Now I know a user can search for People with specific criteria by entering for example
Continent:Europe in the actual Search Box. Sharepoint will refresh the page with the following added to the Query String: k=Continent:Europe and the results will only show people who are from Europe.
So my question is : How can I fix this so that the user does not have to enter the Continent:Europe in the Search box and can just type Europe?
Thanks
One option is to create your own webpart that acts as the search box and replaces the standard one with your custom search box. The advantage of this is that you can more tightly control the user interface and then set up the query passed to the server (with the "k" parameter). You could prepend "Continent:" before the search term entered to help narrow the search.
Another use for this is to append * onto any search term because the People search does include partial words by default.
We did this on one site to simplify the input and allow users to search with one text box (without the advanced features) and then users can use the refinements to narrow the search.

Document Library Crawl

I set up a new scope and passed in the URL for a specific document libary that I created that hold 2 word documents.
For some reason when I start a full crawl, it does not see the 2 word documents.
The word documents have meta data and I've created Managed Properties that map the crawled properties.
I am trying to utilize the Advanced Search webpart to be able to search from this scope. When I enter a search term such as the filename of the word document, no results are returned.
Any ideas?
You need to enable the document library to be searchable. Enable it through the document libraries properties.
Edit
See Harnessing Properties in SharePoint Search
To get to the Document Library Advanced Settings page, from within a given library, select the Document Library Settings menu item from the Settings dropdown, and then select the Advanced settings hyperlink under the General Settings header. Somewhere in there, you should see something like the following image. Make sure that the radio button is set to Yes. Source
(source: bamboosolutions.com)
What account is the crawler running as? Maybe that account doesn't have read permission on the list, so it can't index it.
Can you find information from the same documents in other document libraries, when using the default search scope?
Can you find information from this document library using the default search scope?
Are you trying to create a custom search results page, or just scope?
One thing to try is to check the search crawl log to see if there were any errors when it was searching the library.

Resources