yasiupl / webpack-google-tag-manager-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webpack Google Tag Manager Plugin

A clean and easy way to add Google Tag Manager support to your web project.

npm npm

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',
        }),
    ],
}

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!

About

License:MIT License


Languages

Language:JavaScript 100.0%