diff options
| author | Noah Loomans <noahloomans@gmail.com> | 2016-11-10 16:25:44 +0100 | 
|---|---|---|
| committer | Noah Loomans <noahloomans@gmail.com> | 2016-11-10 16:25:44 +0100 | 
| commit | 462b2c88e85d07b212eece2a30ec69da1d6dce00 (patch) | |
| tree | f6ff3dedc101b264da240bdc949fb276f8c1bb21 /public/javascripts/main.js | |
| parent | 026ec47c693d74307ba780b8e998f0196dd9f195 (diff) | |
added favorite analytics
Diffstat (limited to 'public/javascripts/main.js')
| -rw-r--r-- | public/javascripts/main.js | 26 | 
1 files changed, 25 insertions, 1 deletions
| 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 }) +  })  } | 
