google analytics ajax tracking

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2012-11-09 20:20:09 +01:00
parent 948913bc82
commit 63df1c8f3a
4 changed files with 69 additions and 14 deletions

View File

@@ -56,7 +56,6 @@ MaterioSearchApiAjax = function(){
$.event.trigger(event);
}, 10);
};
function getSearchKeys(){
return $('#materio-search-api-search-form').find('input[name*="searchfield"]').val();
@@ -67,13 +66,12 @@ MaterioSearchApiAjax = function(){
if(keys !== undefined){
keys = keys.replace('/', ' ');
var types = {};
var types = {}, stringTypes = [];
$('#edit-bundles-filter', '#materio-search-api-search-form').find('input[type*="checkbox"]').each(function(i){
$this = $(this);
// if ( $this.attr('checked') ) {
types[$this.val()] = $this.attr('checked');
// }
if ( $this.attr('checked') )
stringTypes.push($this.val());
types[$this.val()] = $this.attr('checked');
});
trace('types', types);
@@ -82,6 +80,15 @@ MaterioSearchApiAjax = function(){
$.event.trigger('loading-content');
_isloadingresults = true;
$('#materio-search-api-search-form').addClass('loading');
// google analytics
var estat = jQuery.Event('record-stat');
estat.path = false;
estat.categorie = 'Search event';
estat.action = 'Search';
estat.label = 'keys :'+ keys +' | filters : '+ stringTypes.join(' ,');
$.event.trigger(estat);
// TODO: record ajax path in a variable from materio_search_api_ajax_init
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys,
{'types':types},
@@ -230,7 +237,20 @@ MaterioSearchApiAjax = function(){
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
trace('viewmode json', json);
if (json.statut == "saved"){
// loadResults(getSearchKeys());
// google analytics
var estat = jQuery.Event('record-stat');
estat.path = false;
estat.categorie = 'Viewmode';
estat.action = vm;
if(isExplore())
estat.label = 'Search results';
if(isActuality())
estat.label = 'Actualities';
$.event.trigger(estat);
$.event.trigger('view-mode-changed');
$('.viewmode-link, .viewmode-link i').removeClass('active');
$btn.addClass('active').find('i').addClass('active');