Skip to content

google-tag-manager

@vuepress/plugin-google-tag-manager

Integrate Google Tag Manager into VuePress.

This plugin will import Google Tag Manager.

Usage

npm i -D @vuepress/plugin-google-tag-manager@next
.vuepress/config.ts
import { googleTagManagerPlugin } from '@vuepress/plugin-google-tag-manager'

export default {
  plugins: [
    googleTagManagerPlugin({
      // options
      id: 'GTM-XXXXXXXXXX',
    }),
  ],
}

Working with Javascript Disabled

If you want Google Tag Manager to work properly when javascript is disabled, you should add the following content to the body part of build template via templateBuild:

<!-- Google Tag Manager (noscript) -->
<noscript>
  <iframe
    src="https://www.googletagmanager.com/ns.html?id=GTM-ABCDEFGH"
    height="0"
    width="0"
    style="display:none;visibility:hidden"
  ></iframe>
</noscript>
<!-- End Google Tag Manager (noscript) -->

Options

idRequiredstring

The container ID of Google Tag Manager, which should start with 'GTM-'.

You can add your container and find its ID.

MIT Licensed