Custom Analytics and Feedback with umami #8434
rehborn
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i'm certain this can be done with less template/css overwriting in the current release, however for those who may need it.
looks pretty similar to the current implementation:
will give you the feedback by page (path), (page) title and feedback value:
recipe
add 2 optional environment variables for
hostandid:mkdocs.yml
set
UMAMI_HOSTandUMAMI_IDas variable in github actions and pass accordingly:workflow
add custom feedback html to the
contentsection and custom javascript to thescriptssection:overrides/main.html{% block content %} {{ super() }} <div class="center" id="feedback"> <div> Was this page helpful? </div> <div> <button data-umami-event="Feedback" data-umami-event-page="/{{ page.url }}" data-umami-event-title="{{ page.title }}" data-umami-event-value="positive"> <span class="twemoji"> {% include ".icons/fontawesome/solid/face-smile-beam.svg" %} </span> </button> <button data-umami-event="Feedback" data-umami-event-page="/{{ page.url }}" data-umami-event-title="{{ page.title }}" data-umami-event-value="neutral"> <span class="twemoji"> {% include ".icons/fontawesome/solid/face-meh.svg" %} </span> </button> <button data-umami-event="Feedback" data-umami-event-page="/{{ page.url }}" data-umami-event-title="{{ page.title }}" data-umami-event-value="negative"> <span class="twemoji"> {% include ".icons/fontawesome/solid/face-frown.svg" %} </span> </button> </div> </div> {% endblock %} {% block scripts %} {{ super() }} {% if config.extra.analytics.host and config.extra.analytics.id %} <script defer> const umamiHost = "{{ config.extra.analytics.host }}"; const umamiId = "{{ config.extra.analytics.id }}"; document.addEventListener("DOMContentLoaded", function () { const script = document.createElement('script'); script.src = "https://" + umamiHost + "/script.js"; script.setAttribute("data-website-id", umamiId); script.defer = true; document.head.appendChild(script); }) feedback = document.getElementById('feedback'); feedback.addEventListener("click", function (e) { feedback.innerHTML = "<b>Thanks for your feedback!</b>"; }) </script> {% endif %} {% endblock %}additional css:
extra.cssBeta Was this translation helpful? Give feedback.
All reactions