Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from main (production) #279

Open
wants to merge 7 commits into
base: juniper/tahoe-prod
Choose a base branch
from
14 changes: 2 additions & 12 deletions lms/templates/body-extra.html
Original file line number Diff line number Diff line change
Expand Up @@ -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')):

Expand Down Expand Up @@ -51,16 +53,4 @@
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/e4awi275';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
% 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:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${customer_gtm_id | n, js_escaped_string}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
% endif

% endif
31 changes: 0 additions & 31 deletions lms/templates/head-extra.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<meta name="image" property="og:image" content="${default_og_image}" />
% 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')}
Expand All @@ -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':
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=${client_ga_code}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '${client_ga_code}');
</script>
% else:
<script>
ga('create', '${client_ga_code}', 'auto', 'clientTracker');
ga('clientTracker.send', 'pageview');
</script>
% endif
% endif
<!-- /Google Analytics code -->
% 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')}
Expand Down
45 changes: 42 additions & 3 deletions lms/templates/partials/analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@
}];
</script>
% 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
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
<script>const loadGTM = function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${customer_gtm_id | n, js_escaped_string}');</script>
};setTimeout(loadGTM.bind(null, window,document,'script','dataLayer','${customer_gtm_id | n, js_escaped_string}'), 1000);</script>
<!-- End Google Tag Manager -->
% endif

Expand Down Expand Up @@ -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':
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=${client_ga_code}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${client_ga_code}');
</script>
% else:
<script>
ga('create', '${client_ga_code}', 'auto', 'clientTracker');
ga('clientTracker.send', 'pageview');
</script>
% endif
% endif
<!-- /Google Analytics code -->
% endif

<%
appsemblerLmsTrackingCode = get_global_settings().get('appsembler_lms_tracking_code')
Expand All @@ -116,4 +148,11 @@
<!-- /new analytics -->
% endif

% endif
% endif

% if customer_gtm_id:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${customer_gtm_id | n, js_escaped_string}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
% endif