diff --git a/lms/envs/common.py b/lms/envs/common.py
index 5bfb4ba5e19..40facc565b7 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -1442,6 +1442,7 @@ def _make_mako_template_dirs(settings):
GOOGLE_SITE_VERIFICATION_ID = ''
GOOGLE_ANALYTICS_LINKEDIN = 'GOOGLE_ANALYTICS_LINKEDIN_DUMMY'
GOOGLE_ANALYTICS_TRACKING_ID = None
+GOOGLE_ANALYTICS_4_ID = None
######################## BRANCH.IO ###########################
BRANCH_IO_KEY = ''
diff --git a/lms/envs/production.py b/lms/envs/production.py
index e68f613ba66..6c7e0815a4a 100644
--- a/lms/envs/production.py
+++ b/lms/envs/production.py
@@ -687,6 +687,7 @@ def get_env_setting(setting):
GOOGLE_ANALYTICS_TRACKING_ID = AUTH_TOKENS.get('GOOGLE_ANALYTICS_TRACKING_ID')
GOOGLE_ANALYTICS_LINKEDIN = AUTH_TOKENS.get('GOOGLE_ANALYTICS_LINKEDIN')
GOOGLE_SITE_VERIFICATION_ID = ENV_TOKENS.get('GOOGLE_SITE_VERIFICATION_ID')
+GOOGLE_ANALYTICS_4_ID = AUTH_TOKENS.get('GOOGLE_ANALYTICS_4_ID')
##### BRANCH.IO KEY #####
BRANCH_IO_KEY = AUTH_TOKENS.get('BRANCH_IO_KEY')
diff --git a/lms/templates/certificates/accomplishment-base.html b/lms/templates/certificates/accomplishment-base.html
index 1fe0456469c..554bb607ccb 100644
--- a/lms/templates/certificates/accomplishment-base.html
+++ b/lms/templates/certificates/accomplishment-base.html
@@ -19,6 +19,19 @@
${document_title}
<%static:css group='style-certificates'/>
+
+
+ <% ga_4_id = static.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID) %>
+ % if ga_4_id:
+
+
+ % endif
diff --git a/lms/templates/main.html b/lms/templates/main.html
index 83416317ba8..a6bac477514 100644
--- a/lms/templates/main.html
+++ b/lms/templates/main.html
@@ -163,6 +163,18 @@
% endif
+<% ga_4_id = static.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID) %>
+% if ga_4_id:
+
+
+% endif
+
<% branch_key = static.get_value("BRANCH_IO_KEY", settings.BRANCH_IO_KEY) %>
% if branch_key and not is_from_mobile_app:
+
+ {% endif %}
+
diff --git a/openedx/core/djangoapps/site_configuration/templatetags/configuration.py b/openedx/core/djangoapps/site_configuration/templatetags/configuration.py
index b5242a53b5b..9de10d3bb07 100644
--- a/openedx/core/djangoapps/site_configuration/templatetags/configuration.py
+++ b/openedx/core/djangoapps/site_configuration/templatetags/configuration.py
@@ -65,3 +65,12 @@ def microsite_template_path(template_name):
"""
template_name = theming_helpers.get_template_path(template_name)
return template_name[1:] if template_name[0] == '/' else template_name
+
+
+@register.simple_tag
+def google_analytics_4_id():
+ """
+ Django template tag that outputs the GOOGLE_ANALYTICS_4_ID:
+ {% google_analytics_4_id %}
+ """
+ return configuration_helpers.get_value("GOOGLE_ANALYTICS_4_ID", settings.GOOGLE_ANALYTICS_4_ID)