aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/analytics.js
blob: a93c8a4dde2a156c0a195946c65d66e91e70b0c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* global ga */

const self = {}

self.send = {}

self.send.search = function (selectedUser, favorite) {
  const hitType = 'event'

  const eventCategory = favorite ? 'search fav' : 'search'

  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, eventCategory, eventAction, eventLabel })
  })
}

module.exports = self