Browse Source

improved path detection for matomo, added filters behaviours matomo event

Bachir Soussi Chiadmi 5 years ago
parent
commit
cc080e920c
4 changed files with 25 additions and 9 deletions
  1. 0 0
      assets/dist/main.js
  2. 0 0
      assets/dist/main.js.map
  3. 20 9
      assets/main.js
  4. 5 0
      assets/modules/header.js

File diff suppressed because it is too large
+ 0 - 0
assets/dist/main.js


File diff suppressed because it is too large
+ 0 - 0
assets/dist/main.js.map


+ 20 - 9
assets/main.js

@@ -28,15 +28,6 @@ var Layout = {
 		// console.log('Layout view : lang', vn.attrs.lang);
 		_i18n.setLang(vn.attrs.lang);
 		console.log('Layout view : path', m.route.get());
-		// matomo
-		// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
-		if(typeof _paq !== 'undefined'){
-		  _paq.push(['setCustomUrl', m.route.get()]);
-		  // _paq.push(['setDocumentTitle', e.title]);
-			_paq.push(['setGenerationTimeMs', 0]);
-		  _paq.push(['trackPageView']);
-			// _paq.push(['trackEvent', 'Audio', 'play', node.title]);
-		}
 
 		return [
 			m(_Header, vn.attrs),
@@ -57,12 +48,32 @@ function init(){
     m.route.prefix("");
 		m.route(document.body, "/fr/connections", {
 			"/:lang/text": {
+				onmatch(args, requestedPath){
+					// matomo
+					if(typeof _paq !== 'undefined'){
+						// console.log('new path ',requestedPath);
+					  _paq.push(['setCustomUrl', requestedPath]);
+					  // _paq.push(['setDocumentTitle', e.title]);
+						_paq.push(['setGenerationTimeMs', 0]);
+					  _paq.push(['trackPageView']);
+					}
+				},
 				render(vn){
 					// console.log('Routing render : vn', vn);
 					return m(Layout, vn.attrs, m(_ModeText, vn.attrs));
 				}
 			},
 			"/:lang/connections": {
+				onmatch(args, requestedPath){
+					// matomo
+					if(typeof _paq !== 'undefined'){
+						// console.log('new path ',requestedPath);
+					  _paq.push(['setCustomUrl', requestedPath]);
+					  // _paq.push(['setDocumentTitle', e.title]);
+						_paq.push(['setGenerationTimeMs', 0]);
+					  _paq.push(['trackPageView']);
+					}
+				},
 				render(vn){
 					return m(Layout, vn.attrs, m(_ModeConnections, vn.attrs));
 				}

+ 5 - 0
assets/modules/header.js

@@ -95,6 +95,11 @@ var _Filters = {
                 // activate the filter
                 let type = e.target.getAttribute("type");
                 _dbs.active_type_filter = type;
+                // matomo
+                if(typeof _paq !== 'undefined'){
+                  // console.log('Matomo Connection closed', vn.state.breadcrumb);
+                  _paq.push(['trackEvent', 'Filter', 'opened', type]);
+                }
               }
               return false;
             }

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