diff --git a/src/template-config.js b/src/template-config.js index 13cf2ed0e..c74763530 100644 --- a/src/template-config.js +++ b/src/template-config.js @@ -28,6 +28,23 @@ module.exports = { og_image_height: 860, // Analytics & Monitoring + // ---------------------- + + // GA4 Measurement ID + // Looks like 'G-XXXXXXXX' + ga4_id: process.env.GA4_ID || '', + + // Universal Analytics Property ID + // Looks like 'UA-99999999-9' ga_tracker: process.env.GA_TRACKER || '', - gtm_id: process.env.GTM_ID || '' + + // Google Tag Manager ID + // Looks like 'GTM-XXXXXXX' + gtm_id: process.env.GTM_ID || '', + + // Google Tag Manager env & auth info for alterative GTM environments + // Looks like '>m_auth=0123456789abcdefghijklm>m_preview=env-00>m_cookies_win=x' + // Taken from the middle of: GTM -> Admin -> Environments -> (environment) -> Get Snippet + // Blank for production + gtm_env_auth: process.env.GTM_ENV_AUTH || '' }; diff --git a/src/template.ejs b/src/template.ejs index cfafbc05f..f2302c91f 100644 --- a/src/template.ejs +++ b/src/template.ejs @@ -8,8 +8,9 @@ + 'https://www.googletagmanager.com/gtm.js?id='+i+dl+'<%- htmlWebpackPlugin.options.gtm_env_auth %>'; + f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','<%- htmlWebpackPlugin.options.gtm_id %>'); + <% } %> @@ -67,7 +68,7 @@
<% if (htmlWebpackPlugin.options.gtm_id) { %> - + <% } %>