Track event when someone previews basic view

We’re interested to know which services are looking at the basic view
preview (even if they’re not turning it on).

This commit logs their service IDs as events into Google Analytics.
This commit is contained in:
Chris Hill-Scott
2018-08-02 12:15:21 +01:00
parent 505c8b1224
commit 77d96032bf
4 changed files with 40 additions and 24 deletions

View File

@@ -0,0 +1,32 @@
(function(Modules) {
"use strict";
if (!ga) return;
function sendEvent(category, action, label) {
ga('send', 'event', category, action, label);
}
Modules.TrackError = function() {
this.start = component => sendEvent(
'Error',
$(component).data('error-type'),
$(component).data('error-label')
);
};
Modules.TrackEvent = function() {
this.start = component => sendEvent(
$(component).data('event-category'),
$(component).data('event-action'),
$(component).data('event-label')
);
};
})(window.GOVUK.Modules);

View File

@@ -1,22 +0,0 @@
(function(Modules) {
"use strict";
Modules.TrackError = function() {
this.start = function(component) {
if (!ga) return;
ga(
'send',
'event',
'Error',
$(component).data('error-type'),
$(component).data('error-label')
);
};
};
})(window.GOVUK.Modules);