From 462b2c88e85d07b212eece2a30ec69da1d6dce00 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Thu, 10 Nov 2016 16:25:44 +0100 Subject: added favorite analytics --- public/javascripts/main.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'public/javascripts/main.js') diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 55bf054..98346dd 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -17,7 +17,8 @@ const nextButton = document.querySelectorAll('input[type="button"]')[1] const currentWeekNode = document.querySelector('.current') const favNode = document.querySelector('.fav') -if (window.location.href.split('?')[1] !== 'nfd') { // nfd = no feature detection +if (!(window.location.href.split('?')[1] && + window.location.href.split('?')[1].indexOf('nfd') >= 0)) { // nfd = no feature detection if (document.querySelector('#schedule').getClientRects()[0].bottom !== document.body.offsetHeight) { window.location = 'http://www.meetingpointmco.nl/Roosters-AL/doc/' } else { @@ -25,6 +26,8 @@ if (window.location.href.split('?')[1] !== 'nfd') { // nfd = no feature detectio window.location = 'http://www.meetingpointmco.nl/Roosters-AL/doc/' } } +} else { + console.log('feature detection is OFF') } let selectedResult = -1 @@ -208,4 +211,25 @@ if (currentFav) { inputNode.value = selectedUser.value scheduleIframe.src = getURLOfUser(offset, selectedUser.type, selectedUser.index + 1) updateFavNode() + + let eventAction + switch (selectedUser.type) { + case 'c': + eventAction = 'Class' + break + case 't': + eventAction = 'Teacher' + break + case 'r': + eventAction = 'Room' + break + case 's': + eventAction = 'Student' + break + } + const eventLabel = selectedUser.value + + ga(function () { + ga('send', { hitType: 'event', eventCategory: 'search fav', eventAction, eventLabel }) + }) } -- cgit v1.1