Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matomo #32

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/aurora/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,3 +842,6 @@ def show_ddt(request): # pragma: no-cover

AZURE_CLIENT_ID = env("AZURE_CLIENT_ID")
AZURE_CLIENT_SECRET = env("AZURE_CLIENT_SECRET")

MATOMO_SITE = env("MATOMO_SITE", default="https://unisitetracker.unicef.io/")
MATOMO_ID = env("MATOMO_ID", default="N/A")
14 changes: 14 additions & 0 deletions src/aurora/core/templatetags/matomo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.conf import settings
from django.template import Library

register = Library()


@register.simple_tag()
def matomo_site():
return settings.MATOMO_SITE


@register.simple_tag()
def matomo_id():
return settings.MATOMO_ID
2 changes: 2 additions & 0 deletions src/aurora/web/templates/_footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% load matomo %}
{% block footer %}
<div class="flex justify-center text-xs footer m-auto pt-1 pb-2 border-t-2 text-gray-400 border-gray-400">
{{ project.build_date }} - {{ LANGUAGE_CODE }} -- {{ project.version }}
</div>
{% include "_matomo.html" %}
{% endblock footer %}
16 changes: 16 additions & 0 deletions src/aurora/web/templates/_matomo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% load matomo %}
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{% matomo_site %}";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{% matomo_id %}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
Loading