Skip to content

Commit 0ee6cd4

Browse files
committed
fix: Submit to GA the Close event of the feedback form as well
1 parent ccbd0a2 commit 0ee6cd4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_assets/js/feedback.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ $(document).ready(function () {
4040

4141
localStorage.setItem(localStorageFeedbackKey(), JSON.stringify(feedbackInfo));
4242

43-
submitToAnalytics(vote);
43+
submitToAnalytics(closed && !vote ? 'close' : vote);
4444
};
4545

4646
var canVote = function () {
4747
var previousVote = getFeedbackInfo();
4848
if (previousVote) {
4949
var previousVoteData = JSON.parse(previousVote);
50-
if (previousVoteData.url === window.location.href) {
50+
if (previousVoteData.url === window.location.href && previousVoteData.vote !== null) {
5151
// You can vote once per week for an article.
5252
return Math.abs(new Date() - new Date(previousVoteData.date)) / 1000 / 60 / 60 >= 168;
5353
}
@@ -85,7 +85,7 @@ $(document).ready(function () {
8585
}
8686
}
8787

88-
var getFeedbackComment = function() {
88+
var getFeedbackComment = function () {
8989
return $('#feedback-other-text-input').val().trim();
9090
}
9191

@@ -203,12 +203,12 @@ $(document).ready(function () {
203203
feedbackProps.isSticky = isSticky;
204204
}
205205

206-
var submitToAnalytics = function (vote) {
206+
var submitToAnalytics = function (data) {
207207
var dataLayer = window.dataLayer || [];
208208
dataLayer.push({
209209
'event': 'virtualEvent',
210210
'eventCategory': 'feedback',
211-
'eventAction': toPascaleCase(vote),
211+
'eventAction': toPascaleCase(data),
212212
'eventLabel': window.location.href
213213
});
214214
}

0 commit comments

Comments
 (0)