From 796bd199384de2a7eca36766ba16219fe1bb892b Mon Sep 17 00:00:00 2001 From: Aline Morelli Date: Thu, 9 Jul 2020 14:24:36 -0300 Subject: [PATCH] fix: add datalayer before gtm snippet (#65) * fix: add datalayer before gtm snippet * chore: bump version --- package.json | 2 +- src/TagManager.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8023f5db..51483670 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-gtm-module", - "version": "2.0.8", + "version": "2.0.9", "description": "React Google Tag Manager Module", "main": "dist/index.js", "scripts": { diff --git a/src/TagManager.js b/src/TagManager.js index f2abf1a1..6c35942f 100644 --- a/src/TagManager.js +++ b/src/TagManager.js @@ -46,7 +46,7 @@ const TagManager = { if (window[dataLayerName]) return window[dataLayerName].push(dataLayer) const snippets = Snippets.dataLayer(dataLayer, dataLayerName) const dataScript = this.dataScript(snippets) - document.head.appendChild(dataScript) + document.head.insertBefore(dataScript, document.head.childNodes[0]) } }