react-google-tag-manager icon indicating copy to clipboard operation
react-google-tag-manager copied to clipboard

Is it possible to use this with react-helmet?

Open damiangreen opened this issue 8 years ago • 2 comments

Is it possible to use this with react-helmet? https://github.com/nfl/react-helmet

damiangreen avatar Oct 23 '17 11:10 damiangreen

I managed to get it working by doing the following:

const x= gtm.scriptAsHTML().replace(/[\n\r]/g, '').replace(/<\/?script>/g, '')

and then in my helmet tag:

  <script type='text/javascript'>
          {x}
        </script>

It would be great if the api supported the above as it's a little hacky. Are pull request welcome?

damiangreen avatar Oct 23 '17 12:10 damiangreen

Does this mean that by using Helmet that GTM can be loaded/unloaded at will?

joetidee avatar Feb 16 '21 00:02 joetidee