Browse Source

added pixik js event tracking

Bachir Soussi Chiadmi 7 years ago
parent
commit
7356c6cec6

File diff suppressed because it is too large
+ 1 - 0
sites/all/modules/figli/edlp_search/assets/dist/scripts/edlp_search.min.js


+ 10 - 0
sites/all/modules/figli/edlp_search/assets/scripts/edlp_search.js

@@ -92,6 +92,16 @@
       'results':data.results_nids
     });
 
+
+    // piwik
+    if(typeof _paq !== 'undefined'){
+      // trackEvent(category, action, [name], [value])
+      var search_name = 'keys:'+data.keys
+        +';langues:'+data.langues
+        +';genres:'+data.genres
+        +';entries:'+data.entry_names.join(',');
+      _paq.push(['trackEvent', 'AjaxSearch', 'Results', search_name, data.results_nids.length]);
+    }
   };
 
   function onResultsLoadFail(jqxhr, textStatus, error){

+ 7 - 1
sites/all/modules/figli/edlp_search/src/Controller/EdlpSearchController.php

@@ -249,6 +249,9 @@ class EdlpSearchController extends ControllerBase {
       'test'=>'search results',
       'keys'=>$this->keys,
       'entries' => $this->entries,
+      'entry_names' => $this->entry_names,
+      'langues' => $this->langues,
+      'genres' => $this->genres,
       'rendered'=> $rendered,
       'results_nids'=>$results_nids,
     ]);
@@ -326,9 +329,12 @@ class EdlpSearchController extends ControllerBase {
 
     // entries
     if (!empty($this->entries)){
+      $terms = entity_load_multiple('taxonomy_term', $this->entries);
+      $this->entry_names = [];
       $entries_condition_group = $query->createConditionGroup();
-      foreach ($this->entries as $tid) {
+      foreach ($terms as $tid => $term) {
         $entries_condition_group->addCondition('field_entrees', (int)$tid, "=");
+        $this->entry_names[] = $term->getName();
       }
       // dpm($entries_condition_group);
       $query->addConditionGroup($entries_condition_group);

+ 19 - 1
sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js

@@ -1,2 +1,20 @@
+console.log('EDLP THEME HISTORY.js');
+// var edlp is provided by edlp_ajax.module file
+if(edlp.redirect){
+  console.log('history redirect', edlp);
+  console.log('window.location', window.location);
+  // window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
+  edlp.sys_path = edlp.sys_path.replace(/^\//, '');
 
-void 0;if(edlp.redirect){void 0;void 0;edlp.sys_path=edlp.sys_path.replace(/^\//,'');edlp.url=window.location.pathname;edlp.hash=window.location.hash;window.localStorage.setItem('edlp_origin',JSON.stringify(edlp));window.location.replace(window.location.origin+'/'+edlp.lang_code);}else{void 0;}
+  // window.localStorage.setItem('edlp_origin_url', window.location.pathname);
+  edlp.url = window.location.pathname;
+
+  // window.localStorage.setItem('edlp_origin_hash', window.location.hash);
+  edlp.hash = window.location.hash;
+
+  window.localStorage.setItem('edlp_origin', JSON.stringify(edlp));
+  // redirect to home
+  window.location.replace(window.location.origin+'/'+edlp.lang_code);
+}else{
+  console.log('history do not redirect');
+}

File diff suppressed because it is too large
+ 1 - 1
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js


File diff suppressed because it is too large
+ 0 - 0
sites/all/themes/custom/edlptheme/assets/dist/styles/app.min.css


+ 6 - 0
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -299,6 +299,12 @@
         // console.log(window.location);
         // /!\ we can not pushestate with absolute url /!\
         history.pushState(state, null, state.url);
+
+        // piwik
+        if(typeof _paq !== 'undefined'){
+          // trackEvent(category, action, [name], [value])
+          _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
+        }
       }
     };
 

Some files were not shown because too many files changed in this diff