Description
react-gtm-module is a JavaScript module for React apps that load Google Tag Manager. It is designed to work with the standard GTM snippet, and it lets you pass a custom dataLayer, several dataLayers from different components, and additional events such as gtm.start. The module needs a gtmId in the form GTM-000000, and it accepts optional dataLayer, dataLayerName, events, auth and preview values. The Environments section explains how to send development and production traffic to different Tag Manager environments, using the auth and preview values that Google Tag Manager shows under Get Snippet. The README also notes that the module may not work correctly when JavaScript is disabled in the browser, which matters when React renders only on the client. Developers who already use Google Tag Manager in a React project will recognise the setup. The package is installed from npm, and its source is public on GitHub.…
Highlights
- Loads Google Tag Manager in React apps
- Custom and multiple dataLayers
- Extra events such as gtm.start
- Tag Manager environments with auth and preview
- Installed from npm
Ratings & Reviews
No ratings yet
Be the first to rate react-gtm-module.
People also visit
react-gtm-module FAQ
What does react-gtm-module do?
It loads Google Tag Manager in a React app using the standard GTM snippet, and lets you push custom data and events.
Where do I find the auth and preview values?
In Google Tag Manager, go to Admin, then Environments, then Actions and Get Snippet. The gtm_auth and gtm_preview values are there.
Can I use several dataLayers?
Yes. You can initialise the module in different components with different dataLayers and send data from each page.
Does it need a GTM ID?
Yes. gtmId is required and looks like GTM-000000.
Is it free?
The source is public on GitHub, so the module is open source.
What are the best react-gtm-module alternatives?
Popular alternatives to react-gtm-module include @sooro-io/react-gtm-module, react-google-recaptcha and react-yandex-metrika. See all react-gtm-module alternatives





















