aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/main.js')
-rw-r--r--public/javascripts/main.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index d0f3280..6a781c2 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -1,3 +1,5 @@
+/* global ga */
+
const fuzzy = require('fuzzy')
const getUsers = require('./getUsers')
const getURLOfUser = require('./getURLOfUser')
@@ -74,6 +76,36 @@ getUsers().then(function (users) {
inputNode.blur()
scheduleIframe.src = getURLOfUser(offset, selectedUser.type, selectedUser.index + 1)
+
+ const hitType = 'event'
+ let eventCategory
+ switch (selectedUser.type) {
+ case 'c':
+ eventCategory = 'Class'
+ break
+ case 't':
+ eventCategory = 'Teacher'
+ break
+ case 'r':
+ eventCategory = 'Room'
+ break
+ case 's':
+ eventCategory = 'Student'
+ break
+ }
+ let eventAction
+ if (selectedUser.isID) {
+ eventAction = 'by id'
+ } else {
+ eventAction = 'by name'
+ }
+ const eventLabel = selectedUser.value
+
+ console.log({ hitType, eventCategory, eventAction, eventLabel })
+
+ ga(function () {
+ ga('send', { hitType, eventCategory, eventAction, eventLabel })
+ })
}
autocompleteNode.addEventListener('click', function (e) {