Google Analytics 4 and Open edX?

I make a workaround for Google Analytics 4 .

  1. 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

  2. Add a line into lms / envs /production.py:
    GOOGLE_ANALYTICS_ACCOUNT_4 = AUTH_TOKENS.get(‘GOOGLE_ANALYTICS_ACCOUNT_4’)

  3. 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