Skip to content

Commit

Permalink
[GA4] Emit page_helpful events for page feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin committed Nov 13, 2023
1 parent eaba498 commit 8f4c47f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions layouts/partials/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ <h2 class="feedback--title">{{- i18n "feedback_title" -}}</h2>
noButton.disabled = true;
};
const sendFeedback = (value) => {
if (typeof ga !== 'function') return;
const args = {
command: 'send',
hitType: 'event',
category: 'Helpful',
action: 'click',
label: window.location.pathname,
value: value
};
ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
if (typeof gtag !== 'function') return;
gtag('event', 'page_helpful', {
'event_category': 'Helpful',
'event_label': window.location.pathname,
'value': value
});
};
yesButton.addEventListener('click', () => {
yesResponse.classList.add('feedback--response__visible');
Expand Down

0 comments on commit 8f4c47f

Please sign in to comment.