npm i --save-dev webpack-google-tag-manager-plugin
yarn add --dev webpack-google-tag-manager-plugin
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',
}),
],
}
Webpack Google Tag Manager Plugin is published under MIT License.
If you have any questions, please contact me via e-mail. For issues, please open an issue!