Add tracking code

This commit is contained in:
Christian Cueni 2024-02-20 07:05:10 +01:00
parent b0c63b8a3e
commit 833dc0e7c7
2 changed files with 7 additions and 0 deletions

View File

@ -736,6 +736,7 @@ CONSTANCE_CONFIG = {
"Default value is empty and will not send any emails. (No regex support!)", "Default value is empty and will not send any emails. (No regex support!)",
), ),
} }
TRACKING_TAG = env("IT_TRACKING_TAG", default="")
if APP_ENVIRONMENT == "local": if APP_ENVIRONMENT == "local":
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development # http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development

View File

@ -58,6 +58,12 @@ def vue_home(request, *args):
# render index.html from `npm run build` # render index.html from `npm run build`
content = loader.render_to_string("vue/index.html", context={}, request=request) content = loader.render_to_string("vue/index.html", context={}, request=request)
# inject Plausible tracking tag
if settings.TRACKING_TAG:
content = content.replace(
"</head>",
f"\n{settings.TRACKING_TAG}\n</head>",
)
return HttpResponse(content) return HttpResponse(content)