mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-30 22:21:16 -04:00
Add a little JS module to track events
Google analytics lets you send: - pageviews - events Page views are used by default. But sometimes you wanna count something which isn’t the user navigating to a new page, or you wanna track something which isn’t just what page they were looking it. This is where events are useful. This commit adds a small JS module that lets us fire off an event when the presence of an element with the right data attributes are present on the page.
This commit is contained in:
22
app/assets/javascripts/errorTracking.js
Normal file
22
app/assets/javascripts/errorTracking.js
Normal file
@@ -0,0 +1,22 @@
|
||||
(function(Modules) {
|
||||
"use strict";
|
||||
|
||||
Modules.TrackEvent = function() {
|
||||
|
||||
this.start = function(component) {
|
||||
|
||||
if (!ga) return;
|
||||
|
||||
ga(
|
||||
'send',
|
||||
'event',
|
||||
'Error',
|
||||
$(component).data('error-type'),
|
||||
$(component).data('error-label')
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
})(window.GOVUK.Modules);
|
||||
Reference in New Issue
Block a user