diff --git a/lms/envs/common.py b/lms/envs/common.py index 18f79f0a3c6..f5884e8dbbf 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1478,6 +1478,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 787e295113a..a56c6f88c1d 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -694,6 +694,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 2f49154d62e..38c306708f4 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 9ee3b6d5b13..ac43e6eba25 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -162,6 +162,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)