Webpack Google Tag Manager Plugin
A clean and easy way to add Google Tag Manager support to your web project.
Installation
npm i --save-dev webpack-google-tag-manager-plugin
yarn add --dev webpack-google-tag-manager-plugin
Examples
Webpack basic configuration for setting up the plugin
import webpack from 'webpack'import HtmlWebpackPlugin from 'html-webpack-plugin'import GoogleTagManagerPlugin from 'webpack-google-tag-manager-plugin' module.exports = { ... plugins: [ new HtmlWebpackPlugin({ ... }), new GoogleTagManagerPlugin({ id: 'your-container-id', }), ],}
Webpack configuration for making use of your environments
import webpack from 'webpack'import HtmlWebpackPlugin from 'html-webpack-plugin'import GoogleTagManagerPlugin from 'webpack-google-tag-manager-plugin' module.exports = { ... plugins: [ new HtmlWebpackPlugin({ ... }), new GoogleTagManagerPlugin({ id: 'your-container-id', auth: 'your-auth-value', preview: 'your-environment-value', }), ],}
License
Webpack Google Tag Manager Plugin is published under MIT License.
Collaboration
If you have any questions, please contact me via e-mail. For issues, please open an issue!