google-analytics

@vuepress/plugin-google-analytics

Integrate Google Analyticsopen in new window into VuePress.

This plugin will import gtag.jsopen in new window for Google Analytics 4open in new window.

Reporting Events

Google Analytics will automatically collect some eventsopen in new window, such as page_view, first_visit, etc.

So if you only want to collect some basic data of your site, you don't need to do anything else except setting the Measurement ID correctly.

After using this plugin, the global gtag() function is available on the window object, and you can use it for custom events reportingopen in new window.

Options

id

  • Type: string

  • Details:

    The Measurement ID of Google Analytics 4, which should start with 'G-'.

    You can follow the instructions hereopen in new window to find your Measurement ID. Notice the difference between Google Analytics 4 Measurement ID (i.e. "G-" ID) and Universal Analytics Tracking ID (i.e. "UA-" ID).

  • Example:

module.exports = {
  plugins: [
    [
      '@vuepress/plugin-google-analytics',
      {
        id: 'G-XXXXXXXXXX',
      },
    ],
  ],
}
1
2
3
4
5
6
7
8
9
10