react-static-plugin-google-tag-manager 📈
This plugin adds the GTM script tag to your HTML files. You only need to supply the GTM ID.
Installation
In an existing react-static site run:
$ yarn add -D react-static-plugin-google-tag-manager
Then add the plugin to your static.config.js
:
plugins: 'react-static-plugin-google-tag-manager' // example configuration id: 'your-gtm-id-here' debug: true ;
Options
In your static.config.js
, you should pass configuration options to the plugin.
id: string
Pass your Google Tag Manager ID in here. The plugin will not work without it.
debug: boolean
Default value: false
When setting debug
to true
, the plugin will not check for stage === 'prod'
and instead always inject the GTM. Useful for debugging data layer events and such locally.
cookieRestriction: object
cookieRestriction?: cookieName: 'string'; value: 'string' | 'number';
Only loads the GTM when a cookie is set to the supplied value.