am 9ae6d37a
: am de295276
: add javascript action events to search suggestions and search results. Allows us to track and compare the success of suggested results and results from Google
* commit '9ae6d37ad09cad5eb3e0caa2f0b4c0a507a243f2': add javascript action events to search suggestions and search results. Allows us to track and compare the success of suggested results and results from Google
This commit is contained in:
commit
2325250e63
1 changed files with 23 additions and 1 deletions
|
@ -1511,6 +1511,12 @@ var gGoogleMatches = new Array();
|
|||
var ROW_COUNT_GOOGLE = 15; // max number of results in list
|
||||
var gGoogleListLength = 0;
|
||||
|
||||
function onSuggestionClick(link) {
|
||||
// When user clicks a suggested document, track it
|
||||
_gaq.push(['_trackEvent', 'Suggestion Click', 'clicked: ' + $(link).text(),
|
||||
'from: ' + $("#search_autocomplete").val()]);
|
||||
}
|
||||
|
||||
function set_item_selected($li, selected)
|
||||
{
|
||||
if (selected) {
|
||||
|
@ -1540,7 +1546,7 @@ function new_suggestion() {
|
|||
$(this).addClass('jd-selected');
|
||||
gSelectedIndex = $('#search_filtered li').index(this);
|
||||
});
|
||||
$li.append('<a></a>');
|
||||
$li.append("<a onclick='onSuggestionClick(this)'></a>");
|
||||
$li.attr('class','show-item');
|
||||
return $li;
|
||||
}
|
||||
|
@ -1894,6 +1900,11 @@ function loadSearchResults() {
|
|||
location.hash = 'q=' + query;
|
||||
});
|
||||
|
||||
// once search results load, set up click listeners
|
||||
searchControl.setSearchCompleteCallback(this, function(control, searcher, query) {
|
||||
addResultClickListeners();
|
||||
});
|
||||
|
||||
// draw the search results box
|
||||
searchControl.draw(document.getElementById("leftSearchControl"), drawOptions);
|
||||
|
||||
|
@ -1972,6 +1983,17 @@ function addTabListeners() {
|
|||
setTimeout(function(){$(tabHeaders[0]).click()},200);
|
||||
}
|
||||
|
||||
// add analytics tracking events to each result link
|
||||
function addResultClickListeners() {
|
||||
$("#searchResults a.gs-title").each(function(index, link) {
|
||||
// When user clicks enter for Google search results, track it
|
||||
$(link).click(function() {
|
||||
_gaq.push(['_trackEvent', 'Google Click', 'clicked: ' + $(this).text(),
|
||||
'from: ' + $("#search_autocomplete").val()]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getQuery(hash) {
|
||||
var queryParts = hash.split('=');
|
||||
|
|
Loading…
Reference in a new issue