diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-21 12:47:43 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-21 12:47:43 +0100 |
commit | f299cd610652535dede504a2ce17191de19ae281 (patch) | |
tree | ec8799afb709a8632e37e433c063395ece4659d5 /public/javascripts/analytics.js | |
parent | 3387256ff71d411d14b863f4a55c28f0356cd6d5 (diff) |
add analytics
Diffstat (limited to 'public/javascripts/analytics.js')
-rw-r--r-- | public/javascripts/analytics.js | 35 |
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 |