I make a workaround for Google Analytics 4 .
-
Add the code below into lms / templates /main.html :
<% ga_acct1 = static.get_value(“GOOGLE_ANALYTICS_ACCOUNT_4”, settings.GOOGLE_ANALYTICS_ACCOUNT_4) %>
% if ga_acct1 == ‘PRO’:< script >
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());
gtag(‘config’, ‘G-XXXXXXXXXX’);
< / script >
% endif -
Add a line into lms / envs /production.py:
GOOGLE_ANALYTICS_ACCOUNT_4 = AUTH_TOKENS.get(‘GOOGLE_ANALYTICS_ACCOUNT_4’) -
Add a line into /edx/etc/lms.yml:
GOOGLE_ANALYTICS_ACCOUNT_4 : ‘PRO’
Because I am not good at JS . Maybe somebody could share a better way to support Google Analytics