diff --git a/app/assets/javascripts/restful_typeahead.js b/app/assets/javascripts/restful_typeahead.js index fe168b40b9..b898a66a6f 100644 --- a/app/assets/javascripts/restful_typeahead.js +++ b/app/assets/javascripts/restful_typeahead.js @@ -15,7 +15,12 @@ $(function() { source: debounce(function (query, process) { var encoded_query = encodeURIComponent(query); var qryType = $(el).attr('qryType'); - return $.getJSON('/api/srch/' + qryType + '?query=' + encoded_query, function (data) { + var queryUrl = 'api/srch/' + qryType + '?query=' + encoded_query; + if (window.hasOwnProperty('ga')) { + tracker = ga.getAll()[0]; + tracker.send("pageview", queryUrl + '&typeahead=true'); + } + return $.getJSON('/' + queryUrl, function (data) { return process(data.items); },'json'); }, 350),