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
  • AI 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
  • AI Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • auto-frontmatter
  • cache
  • google-tag-manager
  • redirect
  • register-components
  • replace-assets

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.

Edit this page on GitHub
Last Updated: 9/28/26, 4:40 AM
Contributors: Mister-Hope
Prev
cache
Next
redirect