improved path detection for matomo, added filters behaviours matomo event

This commit is contained in:
2018-11-05 13:30:30 +01:00
parent 625e893f74
commit cc080e920c
4 changed files with 27 additions and 11 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+20 -9
View File
@@ -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
View File
@@ -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;
}