Преглед на файлове

added better page tracking for piwik

Bachir Soussi Chiadmi преди 6 години
родител
ревизия
249bc608b3

+ 6 - 0
sites/all/modules/figli/edlp_ajax/src/Controller/EdlpAjaxController.php

@@ -25,12 +25,15 @@ class EdlpAjaxController extends ControllerBase {
       switch($this->entity_type){
         case 'node':
           $this->bundle = $this->entity->getType();
+          $this->title = $this->entity->getTitle();
           break;
         case 'taxonomy_term':
           $this->bundle = $this->entity->bundle();
+          $this->title = $this->entity->getName();
           break;
         default:
           $this->bundle = NULL;
+          $this->title = '';
       }
     }
   }
@@ -160,10 +163,13 @@ class EdlpAjaxController extends ControllerBase {
       return render($renderable);
     });
 
+    $title = $this->title;
+    $title .= $this->viewmode != '' && $this->viewmode != 'default' ? ' | ' . $this->viewmode : '';
 
     $data = [
       'date' => time(),
       'id' => $this->id,
+      'title' => $title,
       'view_mode' => $this->viewmode,
       'bundle' => $this->bundle,
       'entity_type' => $this->entity_type,

+ 6 - 0
sites/all/modules/figli/edlp_search/assets/dist/scripts/edlp_search.min.js

@@ -95,6 +95,12 @@
 
     // piwik
     if(typeof _paq !== 'undefined'){
+      // page tracking
+      // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
+      // _paq.push(['setCustomUrl', state.url]);
+      // _paq.push(['setDocumentTitle', data.title]);
+      // _paq.push(['trackPageView']);
+
       // trackEvent(category, action, [name], [value])
       var search_name = 'keys:'+data.keys
         +';langues:'+data.langues

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

@@ -95,6 +95,12 @@
 
     // piwik
     if(typeof _paq !== 'undefined'){
+      // page tracking
+      // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
+      // _paq.push(['setCustomUrl', state.url]);
+      // _paq.push(['setDocumentTitle', data.title]);
+      // _paq.push(['trackPageView']);
+
       // trackEvent(category, action, [name], [value])
       var search_name = 'keys:'+data.keys
         +';langues:'+data.langues

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

@@ -328,9 +328,9 @@ class EdlpSearchController extends ControllerBase {
     }
 
     // entries
+    $this->entry_names = [];
     if (!empty($this->entries)){
       $terms = entity_load_multiple('taxonomy_term', $this->entries);
-      $this->entry_names = [];
       $entries_condition_group = $query->createConditionGroup();
       foreach ($terms as $tid => $term) {
         $entries_condition_group->addCondition('field_entrees', (int)$tid, "=");

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

@@ -302,6 +302,12 @@
 
         // piwik
         if(typeof _paq !== 'undefined'){
+          // page tracking
+          // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
+          _paq.push(['setCustomUrl', state.url]);
+          _paq.push(['setDocumentTitle', data.title]);
+          _paq.push(['trackPageView']);
+          // js event
           // trackEvent(category, action, [name], [value])
           _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
         }

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

@@ -302,6 +302,12 @@
 
         // piwik
         if(typeof _paq !== 'undefined'){
+          // page tracking
+          // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
+          _paq.push(['setCustomUrl', state.url]);
+          _paq.push(['setDocumentTitle', data.title]);
+          _paq.push(['trackPageView']);
+          // js event
           // trackEvent(category, action, [name], [value])
           _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
         }