diff --git a/agagd/agagd/settings/base.py b/agagd/agagd/settings/base.py index 7f5e9c2c..5b3aca6b 100644 --- a/agagd/agagd/settings/base.py +++ b/agagd/agagd/settings/base.py @@ -101,6 +101,7 @@ 'django.contrib.messages.context_processors.messages', # Custom context_processors 'django.template.context_processors.request', + 'agagd_core.context_processors.google_analytics_tracking_id', ], 'loaders': [ 'django.template.loaders.filesystem.Loader', diff --git a/agagd/agagd/settings/prod.py b/agagd/agagd/settings/prod.py index c13f6b26..80e8fc8c 100644 --- a/agagd/agagd/settings/prod.py +++ b/agagd/agagd/settings/prod.py @@ -7,6 +7,8 @@ else: DEBUG = False +GOOGLE_ANALYTICS_TRACKING_ID = os.getenv('GOOGLE_ANALYTICS_TRACKING_ID', '') + ADMIN_ENABLED = False # For SECRET_KEY, we want to be absolutely certain a value is provided diff --git a/agagd/agagd_core/context_processors/__init__.py b/agagd/agagd_core/context_processors/__init__.py new file mode 100644 index 00000000..a7989831 --- /dev/null +++ b/agagd/agagd_core/context_processors/__init__.py @@ -0,0 +1 @@ +from .google_analytics import * diff --git a/agagd/agagd_core/context_processors/google_analytics.py b/agagd/agagd_core/context_processors/google_analytics.py new file mode 100644 index 00000000..5bb9b660 --- /dev/null +++ b/agagd/agagd_core/context_processors/google_analytics.py @@ -0,0 +1,3 @@ +def google_analytics_tracking_id(request): + from django.conf import settings + return {'google_analytics_tracking_id': settings.GOOGLE_ANALYTICS_TRACKING_ID} diff --git a/agagd/templates/base.html b/agagd/templates/base.html index 75ecb129..ea3002cf 100644 --- a/agagd/templates/base.html +++ b/agagd/templates/base.html @@ -12,6 +12,19 @@ {% endblock %} + {% block google_analytics %} + {% if google_analytics_tracking_id != '' %} + + + + {% endif %} + {% endblock %}