Skip to content

Commit

Permalink
Merge pull request #32 from unicef/matomo
Browse files Browse the repository at this point in the history
matomo
  • Loading branch information
domdinicola authored Nov 9, 2023
2 parents 01866dc + 9f09caa commit 3016178
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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 -->

0 comments on commit 3016178

Please sign in to comment.