Help Including Google Analytics in Learning MFE

Hello all,

Recently we’ve upgraded our OpenEDX instance to Nutmeg.2 and I’m noticing within the newly integrated frontend learning app there is no tracking occurring with Google Analytics. After digging a little further I’m unable to identify where/if the base EDX google analytics configuration is carried over to the Learning App’s template.

Is there a method to add the necessary Google Analytics configurations to the base template without replacing the entire MFE?

configuration information:

  • openedx running with Tutor v14.0.5
  • custom fork of open-release/nutmeg.2

Hi Crivet @crivet,

Did u find any credible solution we also wanted to use Google Analytics and other analytics solutions in our system

Hey,

A quick but may be not the most efficient way to do it, is just to add a script tag in the HTML template of the learning MFE.

This the file I am referring to frontend-app-learning/index.html at master · openedx/frontend-app-learning · GitHub.

So just edit the file before you build it.

@Shailendra_Kumar, the solution suggested by @ghassan is the one that i went with.

I made a custom fork of frontend-app-learning and added in the code snippet provided by Google analytics.

if you’re using tutor for your deployment, you will need to point the build to the forked repo by adding the following to your config.yml and pointing it to your custom fork:

...
MFE_LEARNING_MFE_APP:
  name: learning
  port: 2000
  repository: https://github.com/YOUR_REPO/frontend-app-learning
  version: YOUR_BRANCH_NAME
...

and perform a rebuild with no cache on the mfe container:
tutor images build mfe --no-cache

I believe i found these settings from exploring tutor’s mfe repository and poking around to get an understanding, located here: GitHub - overhangio/tutor-mfe

also thanks for stepping in @ghassan , marking your answer as the solution as it’s what i ultimately went with. I’m sure eventually this/all mfe’s should incorporate the specified analytics configs of the openedx config, but for the time being this is a functional solution

Do we know for sure if Google Analytics 4 will be supported going forward? The code snippet supporting Google Analytics in lms/templates/main.html still uses Google Universal Analytics which will no longer work on July 1, 2023.

Like you said, we have to hope that this code will be updated and that all mfe should incorporate it.

@arbrandes what do you know about MFE and Google Analytics going forward?

Not much. I can see this conversation about pulling in custom JS into the frontend-app-learning header - which could theoretically allow things like pulling in GA without forking the MFE - but that’s been closed since.

I think this could be part of a more general discussion about plugins, which can be a subset of this draft OEP I’m working on. (Having a single SPA for the LMS would make it much easier to keep track of everything.)

1 Like