Skip to content

Commit f4d74e7

Browse files
committed
Make feedback buttons compatible with GA4
Signed-off-by: Chris Abraham <[email protected]>
1 parent 9dc2c8e commit f4d74e7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

layouts/partials/feedback.html

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,18 @@ <h2 class="feedback--title">{{ T "feedback_title" }}</h2>
3535
noButton.disabled = true;
3636
};
3737
const sendFeedback = (value) => {
38-
if (typeof ga !== 'function') return;
39-
const args = {
40-
command: 'send',
41-
hitType: 'event',
42-
category: 'Helpful',
43-
action: 'click',
44-
label: window.location.pathname,
45-
value: value
46-
};
47-
ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
38+
if (typeof gtag !== 'function') return;
39+
gtag('event', 'page_helpful', {
40+
'event_category': 'Helpful',
41+
'event_label': window.location.pathname,
42+
'value': value
43+
});
4844
};
4945
yesButton.addEventListener('click', () => {
5046
yesResponse.classList.add('feedback--response__visible');
5147
disableButtons();
52-
sendFeedback(1);
48+
{{ $maxValue := .max_value | default 100 -}}
49+
sendFeedback({{ $maxValue }});
5350
});
5451
noButton.addEventListener('click', () => {
5552
noResponse.classList.add('feedback--response__visible');

0 commit comments

Comments
 (0)