diff --git a/innovedus_cms/mysite/context_processors.py b/innovedus_cms/mysite/context_processors.py
new file mode 100644
index 0000000..ee31c19
--- /dev/null
+++ b/innovedus_cms/mysite/context_processors.py
@@ -0,0 +1,7 @@
+from django.conf import settings
+
+
+def ga4(request):
+ return {
+ "ga4_measurement_id": getattr(settings, "GA4_MEASUREMENT_ID", ""),
+ }
diff --git a/innovedus_cms/mysite/settings/base.py b/innovedus_cms/mysite/settings/base.py
index e040ad4..4b43aa4 100644
--- a/innovedus_cms/mysite/settings/base.py
+++ b/innovedus_cms/mysite/settings/base.py
@@ -26,6 +26,9 @@ def env_list(name, default):
return default
+GA4_MEASUREMENT_ID = os.environ.get("GA4_MEASUREMENT_ID", "").strip()
+
+
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
@@ -87,6 +90,7 @@ TEMPLATES = [
"django.contrib.messages.context_processors.messages",
"wagtail.contrib.settings.context_processors.settings",
"home.context_processors.navigation_pages",
+ "mysite.context_processors.ga4",
],
},
},
diff --git a/innovedus_cms/mysite/templates/base.html b/innovedus_cms/mysite/templates/base.html
index a406f9a..f34b3cf 100644
--- a/innovedus_cms/mysite/templates/base.html
+++ b/innovedus_cms/mysite/templates/base.html
@@ -17,6 +17,15 @@
{% endif %}
+ {% if ga4_measurement_id %}
+
+
+ {% endif %}
{# Force all links in the live preview panel to be opened in a new tab #}
{% if request.in_preview_panel %}