Thanks for this contribution.
On NAU platform we have been using Google Tag Manager for quite a while. We have it installed on both Open edX and Marketing site (using RichieCMS).
We have it installed on our custom theming for older Django based screens, and on our custom MFE footer.
References for older Django based screens:
- nau-themes/edx-platform/nau-basic/lms/templates/head-extra.html at daa7b28139fde9a3c68a555a52a3fa601741f1cb · fccn/nau-themes · GitHub
- nau-themes/edx-platform/nau-basic/lms/templates/body-initial.html at daa7b28139fde9a3c68a555a52a3fa601741f1cb · fccn/nau-themes · GitHub
References for newest MFE:
- frontend-component-footer-nau/src/services/gtmLoader.js at 6751d9ef15672ab1ce3714f9a213985bf8acc5d7 · fccn/frontend-component-footer-nau · GitHub
- frontend-component-footer-nau/src/components/Footer.jsx at 6751d9ef15672ab1ce3714f9a213985bf8acc5d7 · fccn/frontend-component-footer-nau · GitHub
What I want to highlight is the possibility to have custom GTM environments. This is important when you have to manage a complex configuration on GTM. Like test it before on DEV/STAGE environments before publishing to production. Just view our implementation and be inspired by it!
About the Google Tag Manager (GTM) and its integration with cookie consent.
IMO you shouldn’t depend the execution of GTM when you give cookie consent.
GTM has a built-in support for managing consent quite good. You can use a third party consent management tool that support “Google Consent Mode v2”, there are different solutions. You can view some of the possible solutions in this page: Tag Manager consent mode support - Tag Manager Help
We have different trackers that start when you give consent on our platform that are installed directly via GTM. So we don’t have to install them on every UI technology that we have, including Open edX.
For example we use GTM to start other tags, that are injected on RichieCMS and Open edX Django and MFE screens:
- Google Analytics v4
- Cookie Consent
- Browser upgrade
- Facebook tracking
- Linkedin tracking
- Support Widget
- Maintenance banner
We also use custom dimensions on Google Analytics. On my last iteration on GTM, I moved that code to be calculated inside the GTM using a small JS, it parses the course id ex: course-v1:FCT+TPag+2024_T3
from the URLs, process and passes them to Google Analytics. With this you can have your Google Analytics metrics divided by Organization, Course code and edition. I also have a similar implementation on our marketing site.
Kind regards.