From bbd1c7cf9cff9cb54cb713185c8f9ef6dd62b020 Mon Sep 17 00:00:00 2001 From: Chris Abraham Date: Wed, 22 Nov 2023 16:53:28 +0700 Subject: [PATCH] Added feedback buttons to pages Signed-off-by: Chris Abraham --- website/layouts/_default/content.html | 17 +++++++++++++++++ website/layouts/partials/feedback.html | 19 ++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 website/layouts/_default/content.html diff --git a/website/layouts/_default/content.html b/website/layouts/_default/content.html new file mode 100644 index 00000000..d8a1ecb0 --- /dev/null +++ b/website/layouts/_default/content.html @@ -0,0 +1,17 @@ +
+

{{ .Title }}

+ {{ with .Params.description }}
{{ . | markdownify }}
{{ end }} + {{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }} + {{ partial "reading-time.html" . }} + {{ end }} + {{ .Content }} + {{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable)) }} + {{ partial "feedback.html" .Site.Params.ui.feedback }} +
+ {{ end }} + {{ if (.Site.Params.DisqusShortname) }} +
+ {{ partial "disqus-comment.html" . }} + {{ end }} +
{{ partial "page-meta-lastmod.html" . }}
+
diff --git a/website/layouts/partials/feedback.html b/website/layouts/partials/feedback.html index 966fd0b3..d79f34fe 100644 --- a/website/layouts/partials/feedback.html +++ b/website/layouts/partials/feedback.html @@ -35,21 +35,18 @@ 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.href, + 'value': value + }); }; yesButton.addEventListener('click', () => { yesResponse.classList.add('feedback--response__visible'); disableButtons(); - sendFeedback(1); + {{ $maxValue := .max_value | default 100 -}} + sendFeedback({{ $maxValue }}); }); noButton.addEventListener('click', () => { noResponse.classList.add('feedback--response__visible');