feat: replace gtag with google-tag-manager plugin for GTM support#11709
feat: replace gtag with google-tag-manager plugin for GTM support#11709ceasermikes002 wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @ceasermikes002! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Pre-flight checklist
Motivation
This PR resolves issue #2407 regarding GTM support and GDPR compliance.
Previously, the Docusaurus website used the
gtagoption in@docusaurus/preset-classic, which only supports Google Analytics 4 (GA4) viaplugin-google-gtag. This configuration does not support Google Tag Manager (GTM) container IDs (GTM-XXXXXXX), which are essential for implementing GDPR-compliant consent management (e.g., controlling when tags fire based on user consent).This change:
gtagconfiguration inpreset-classicto prevent double-firing or conflicts.@docusaurus/plugin-google-tag-managerto the website configuration.GTM-XXXXXXX) to demonstrate the correct setup pattern.This allows the Docusaurus website (and users copying this pattern) to leverage GTM for advanced tag management and consent enforcement.
Test Plan
I verified these changes by building the website locally and inspecting the generated HTML.
Steps to verify:
yarn workspace website build.website/build/index.html.Verification Results:
gtm.jsscript injection logic is present in the<head>.<noscript>iframe for GTM is correctly injected at the start of the<body>.GTM-XXXXXXXis present in the generated code.gtagscript is no longer being injected by the preset.Related issues/PRs
Closes #2407