added entree page tracking, added title to ajax response for tracking (production, agenda, search)

This commit is contained in:
2018-04-18 10:29:46 +02:00
parent 65d95036c0
commit f7225cdd01
7 changed files with 62 additions and 5 deletions
@@ -79,7 +79,8 @@ class AgendaController extends ControllerBase {
});
$data = [
'rendered'=> $rendered
'rendered'=> $rendered,
'title'=>'Agenda',
];
// translations links
@@ -662,13 +662,20 @@
var $li = $link.parents('li');
var sys_path = $link.attr('data-drupal-link-system-path');
var url = $link.attr('href');
var title = $link.text();
if(!$li.is('.opened')){
_$entrees_block_termlinks.parents('li').removeClass('opened');
$li.addClass('opened');
$li.parents('.item-list').addClass('opened')
filterEntree(tid);
if(bubbling){
_$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
_$body.trigger({
'type':'open_entree',
'tid':tid,
'url':url,
'sys_path':sys_path,
'title':title
});
}
// bubbling is true only when event is a real click on entree link
}else if(bubbling){
@@ -800,6 +807,10 @@
_no_articles_nodes[i].fade();
}
updateRandomPlaylist(_articles_nodes);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'on']);
}
};
function deactivateArticlesFilter(){
//console.log('deactivateArticlesFilter');
@@ -808,6 +819,10 @@
_no_articles_nodes[i].unFade();
}
updateRandomPlaylist(_playlist);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'off']);
}
};
function shutDownArticles(){
// shutdown articles if active
@@ -662,13 +662,20 @@
var $li = $link.parents('li');
var sys_path = $link.attr('data-drupal-link-system-path');
var url = $link.attr('href');
var title = $link.text();
if(!$li.is('.opened')){
_$entrees_block_termlinks.parents('li').removeClass('opened');
$li.addClass('opened');
$li.parents('.item-list').addClass('opened')
filterEntree(tid);
if(bubbling){
_$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
_$body.trigger({
'type':'open_entree',
'tid':tid,
'url':url,
'sys_path':sys_path,
'title':title
});
}
// bubbling is true only when event is a real click on entree link
}else if(bubbling){
@@ -800,6 +807,10 @@
_no_articles_nodes[i].fade();
}
updateRandomPlaylist(_articles_nodes);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'on']);
}
};
function deactivateArticlesFilter(){
//console.log('deactivateArticlesFilter');
@@ -808,6 +819,10 @@
_no_articles_nodes[i].unFade();
}
updateRandomPlaylist(_playlist);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'off']);
}
};
function shutDownArticles(){
// shutdown articles if active
@@ -102,6 +102,7 @@ class ProductionsController extends ControllerBase {
$data = [
'rendered'=> $rendered,
'title'=> 'Productions',
// 'block' => array(
// 'rendered'=> \Drupal::service('renderer')->renderRoot($block_render),
// 'region'=> str_replace('_', '-', $block->getRegion()),
@@ -120,7 +121,7 @@ class ProductionsController extends ControllerBase {
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data ['translations_links'] = $translations_rendered;
}
@@ -78,7 +78,8 @@ class EdlpSearchController extends ControllerBase {
$rendered = render($this->renderable);
$data = [
'rendered' => $rendered
'rendered' => $rendered,
'title' => 'Search',
];
// translations links
@@ -79,6 +79,18 @@
// };
var state = getSysPathState(e.sys_path);
history.pushState(state, null, e.url);
// 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', e.url]);
_paq.push(['setDocumentTitle', e.title]);
_paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
// _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
}
}
})
.on('close_entree', function(e){
@@ -79,6 +79,18 @@
// };
var state = getSysPathState(e.sys_path);
history.pushState(state, null, e.url);
// 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', e.url]);
_paq.push(['setDocumentTitle', e.title]);
_paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
// _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
}
}
})
.on('close_entree', function(e){