aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/analytics.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-01-08 11:48:13 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-01-08 11:48:13 +0100
commit320c18af3ee9cbeaaae3d4796dd7f15a5ac90889 (patch)
treed63339d425a2a6a20c883d896b9ed492272d6085 /public/javascripts/analytics.js
parent4e8da42863406764a659a7337e774ad216d356c9 (diff)
parentdea89e1ec600b302a8db33dd48080b901aee7c7e (diff)
Merge branch 'master' of github.com:nloomans/rooster-mml
Diffstat (limited to 'public/javascripts/analytics.js')
-rw-r--r--public/javascripts/analytics.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/public/javascripts/analytics.js b/public/javascripts/analytics.js
new file mode 100644
index 0000000..a93c8a4
--- /dev/null
+++ b/public/javascripts/analytics.js
@@ -0,0 +1,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