diff --git a/docusaurus.config.js b/docusaurus.config.js index ab4f7d5234..c468061294 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 0000000000..0b2c5bf571 --- /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: ``, + }, + ], + }; + }, + }; +};