aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/main.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-09-09 13:18:34 +0200
committerNoah Loomans <noahloomans@gmail.com>2016-09-09 13:18:34 +0200
commit06e00475724bbcf0c99a1c8a430b97103822360b (patch)
treeb26b5b3b39c0866a4d440017ceee844ebf537a96 /public/javascripts/main.js
parent3f7be1f445dd1e1e51d3e321f8dcda8a0b5d2a30 (diff)
add search term to ga
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) {