react-google-tagmanager
Google Tag Manager code strings for React server page templates.
Installation
$ npm i @info.nl/react-google-tagmanager -S
Usage
import reactGoogleTagmanager from "react-google-tagmanager";
class Html extends Component {
render() {
const tagmanager = reactGoogleTagmanager(
process.env.GOOGLE_TAGMANAGER_ID,
'myLayer'
);
return (
<html>
...
<body>
<noscript
dangerouslySetInnerHTML={{__html: tagmanager.noscript}}
></noscript>
<script
dangerouslySetInnerHTML={{__html: tagmanager.script}}
></script>
...
</body>
</html>
)
}
}
License
MIT