mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Track virtual page view when enabling basic view
So we can see what pages people go to after turning it on.
This commit is contained in:
@@ -1,14 +1,24 @@
|
|||||||
|
let stripUUIDs = string => string.replace(
|
||||||
|
/[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/g, '…'
|
||||||
|
);
|
||||||
|
|
||||||
(function(Modules) {
|
(function(Modules) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (!ga) return;
|
|
||||||
|
|
||||||
function sendEvent(category, action, label) {
|
function sendEvent(category, action, label) {
|
||||||
|
|
||||||
|
if (!ga) return;
|
||||||
ga('send', 'event', category, action, label);
|
ga('send', 'event', category, action, label);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendVirtualPageView(path) {
|
||||||
|
|
||||||
|
if (!ga) return;
|
||||||
|
ga('send', 'pageview', stripUUIDs('/virtual' + path));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Modules.TrackError = function() {
|
Modules.TrackError = function() {
|
||||||
|
|
||||||
this.start = component => sendEvent(
|
this.start = component => sendEvent(
|
||||||
@@ -29,4 +39,18 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Modules.TrackFormSubmission = function() {
|
||||||
|
|
||||||
|
this.start = component => {
|
||||||
|
|
||||||
|
$(component).on('submit', function() {
|
||||||
|
|
||||||
|
let formData = $('input[name!=csrf_token]', this).serialize();
|
||||||
|
sendVirtualPageView(window.location.pathname + '?' + formData);
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
})(window.GOVUK.Modules);
|
})(window.GOVUK.Modules);
|
||||||
|
|||||||
@@ -128,10 +128,7 @@
|
|||||||
ga('set', 'anonymizeIp', true);
|
ga('set', 'anonymizeIp', true);
|
||||||
ga('set', 'displayFeaturesTask', null);
|
ga('set', 'displayFeaturesTask', null);
|
||||||
ga('set', 'transport', 'beacon');
|
ga('set', 'transport', 'beacon');
|
||||||
// strip UUIDs
|
page = window.location.pathname + window.location.search;
|
||||||
page = (window.location.pathname + window.location.search).replace(
|
ga('send', 'pageview', stripUUIDs(page));
|
||||||
/[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/g, '…'
|
|
||||||
)
|
|
||||||
ga('send', 'pageview', page);
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<form method="post" class="column-five-sixths">
|
<form
|
||||||
|
method="post"
|
||||||
|
class="column-five-sixths"
|
||||||
|
data-module="track-form-submission"
|
||||||
|
>
|
||||||
<h1 class="heading-large">Basic view</h1>
|
<h1 class="heading-large">Basic view</h1>
|
||||||
<p>
|
<p>
|
||||||
Basic view lets you restrict a team member to only:
|
Basic view lets you restrict a team member to only:
|
||||||
|
|||||||
Reference in New Issue
Block a user