From 6353b2b8ae4b56a20c9e939f533db6a8d66767e7 Mon Sep 17 00:00:00 2001 From: Manuel Salazar Date: Wed, 17 Dec 2025 09:02:22 -0700 Subject: [PATCH] feat: Implement new Google Tag Manager --- docusaurus.config.js | 1 + plugins/gtm-plugin/index.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 plugins/gtm-plugin/index.js diff --git a/docusaurus.config.js b/docusaurus.config.js index ab4f7d52345..c4680612946 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -131,6 +131,7 @@ const config = { sidebarPath: './sidebars.js', }, ], + './plugins/gtm-plugin', ], presets: [ diff --git a/plugins/gtm-plugin/index.js b/plugins/gtm-plugin/index.js new file mode 100644 index 00000000000..0b2c5bf5713 --- /dev/null +++ b/plugins/gtm-plugin/index.js @@ -0,0 +1,26 @@ +module.exports = function (context, options) { + return { + name: 'docusaurus-plugin-gtm-secondary', + injectHtmlTags() { + return { + headTags: [ + { + tagName: 'script', + innerHTML: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': +new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], +j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= +'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); +})(window,document,'script','dataLayer','GTM-TVR3P3LC');`, + }, + ], + preBodyTags: [ + { + tagName: 'noscript', + innerHTML: ``, + }, + ], + }; + }, + }; +};