VuePress EcosystemVuePress Ecosystem
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • cache
  • google-tag-manager
  • redirect
  • register-components

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

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

id

  • Type: string

  • Details:

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

    You add your container and find its ID here.

  • Example:

.vuepress/config.ts
export default {
  plugins: [
    googleTagManagerPlugin({
      id: 'GTM-XXXXXXXXXX',
    }),
  ],
}
Edit this page on GitHub
Last Updated:: 4/12/25, 7:03 PM
Contributors: Mister-Hope
Prev
cache
Next
redirect