diff --git a/lms/templates/body-extra.html b/lms/templates/body-extra.html index 341a00be..99f2b308 100644 --- a/lms/templates/body-extra.html +++ b/lms/templates/body-extra.html @@ -2,6 +2,8 @@ <%! import hmac %> <%! import hashlib %> +<%include file="partials/analytics.html" /> + ## Renders when Cookie Banner is disabled or when it is enabled and user has dismissed (accepted) it: % if (not get_global_settings().get('cookie_notification_enabled', False)) or (get_global_settings().get('cookie_notification_enabled', False) and (request.COOKIES.get('cookieconsent_status', '') == 'dismiss')): @@ -51,16 +53,4 @@ % endif - <%! from openedx.core.djangolib.js_utils import js_escaped_string %> - <% - customer_gtm_id = get_global_settings().get('customer_gtm_id') - %> - - % if customer_gtm_id: - - - - % endif - % endif diff --git a/lms/templates/head-extra.html b/lms/templates/head-extra.html index 58eed301..2268a7da 100644 --- a/lms/templates/head-extra.html +++ b/lms/templates/head-extra.html @@ -48,7 +48,6 @@ % endif -<%include file="partials/analytics.html" /> % if get_global_settings().get('default_additional_site_head_content', ''): ${get_global_settings().get('default_additional_site_head_content')} @@ -57,36 +56,6 @@ ## Renders when Cookie Banner is disabled or when it is enabled and user has dismissed (accepted) it: % if (not get_global_settings().get('cookie_notification_enabled', False)) or (get_global_settings().get('cookie_notification_enabled', False) and (request.COOKIES.get('cookieconsent_status', '') == 'dismiss')): - <% - appsembler_ga_code = get_global_settings().get('appsembler_ga_code', ''); - client_ga_code = get_global_settings().get('client_ga_code', ''); - client_ga_enabled = get_global_settings().get('client_ga_enabled', True); - client_ga_version = get_global_settings().get('client_ga_version', 'v3'); - %> - % if SHOW_GOOGLE_ANALYTICS: - % if client_ga_code and client_ga_enabled: - ## for now Appsembler is still using v3 Universal Analytics and some customers do too. - ## once Appsembler and all customers shift to v4 we remove this condition - % if client_ga_version == 'v4': - - - - % else: - - % endif - % endif - - % endif - % if get_global_settings().get('cookie_accepted_additional_site_head_content', ''): % if request.COOKIES.get('cookieconsent_status', '') == 'dismiss': ${get_global_settings().get('cookie_accepted_additional_site_head_content')} diff --git a/lms/templates/partials/analytics.html b/lms/templates/partials/analytics.html index 10d97314..ab87db82 100644 --- a/lms/templates/partials/analytics.html +++ b/lms/templates/partials/analytics.html @@ -60,12 +60,15 @@ }]; % endif + ## Add a timeout delay to GTM initialization to avoid breaking video module loading from YouTube + ## with Google Analytics v<4 with Measure Videos turneed on + ## see: https://discuss.openedx.org/t/first-video-on-lesson-dont-work/3836/3 - + };setTimeout(loadGTM.bind(null, window,document,'script','dataLayer','${customer_gtm_id | n, js_escaped_string}'), 1000); % endif @@ -94,6 +97,35 @@ Dimension3: Visited course name Dimension4: LMS or Studio --> + <% + appsembler_ga_code = get_global_settings().get('appsembler_ga_code', ''); + client_ga_code = get_global_settings().get('client_ga_code', ''); + client_ga_enabled = get_global_settings().get('client_ga_enabled', True); + client_ga_version = get_global_settings().get('client_ga_version', 'v3'); + %> + + % if SHOW_GOOGLE_ANALYTICS: + % if client_ga_code and client_ga_enabled: + ## for now Appsembler is still using v3 Universal Analytics and some customers do too. + ## once Appsembler and all customers shift to v4 we remove this condition + % if client_ga_version == 'v4': + + + + % else: + + % endif + % endif + + % endif <% appsemblerLmsTrackingCode = get_global_settings().get('appsembler_lms_tracking_code') @@ -116,4 +148,11 @@ % endif -% endif \ No newline at end of file +% endif + +% if customer_gtm_id: + + + +% endif