Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fix GTM tag being added to the body instead the head of the document
Carlos Monastyrski5d5a77a74dd9
diff --git a/frontend/src/hooks/useGtm.ts b/frontend/src/hooks/useGtm.tsindex 4a1907eaa6..d1f5d4748d 100644--- a/frontend/src/hooks/useGtm.ts+++ b/frontend/src/hooks/useGtm.ts@@ -16,13 +16,6 @@ export const useGtm = () => {useEffect(() => {if (!isCloudHostname()) return undefined;- // Inject GTM script- const script = document.createElement("script");- script.id = GTM_SCRIPT_ID;- script.async = true;- script.src = `https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`;- document.head.appendChild(script);-// Inject noscript iframeconst noscript = document.createElement("noscript");noscript.id = GTM_NOSCRIPT_ID;@@ -33,7 +26,14 @@ export const useGtm = () => {iframe.style.display = "none";iframe.style.visibility = "hidden";noscript.appendChild(iframe);- document.body.insertBefore(noscript, document.body.firstChild);+ document.head.insertBefore(noscript, document.head.firstChild);++ // Inject GTM script+ const script = document.createElement("script");+ script.id = GTM_SCRIPT_ID;+ script.async = true;+ script.src = `https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`;+ document.head.insertBefore(script, document.head.firstChild);return () => {document.getElementById(GTM_SCRIPT_ID)?.remove();