holidaycheck / react-google-tag-manager

This repository contains a react based implementation for Google's Tag Manager snippet.
MIT License
192 stars 31 forks source link

Is it possible to use this with react-helmet? #65

Open damiangreen opened 6 years ago

damiangreen commented 6 years ago

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

damiangreen commented 6 years ago

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?

joetidee commented 3 years ago

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