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
  • baidu-analytics
  • clarity-analytics
  • google-analytics
  • umami-analytics

baidu-analytics

@vuepress/plugin-baidu-analytics

This plugin integrates Baidu Analytics (Baidu Tongji) into your VuePress site, allowing you to track visitor traffic and user interactions.

Tips

Please disable the SPA mode in your Baidu Analytics settings.

This plugin automatically handles page view reporting on route changes. Enabling Baidu's built-in SPA mode may result in duplicate data or incorrect statistics.

Usage

npm i -D @vuepress/plugin-baidu-analytics@next
.vuepress/config.ts
import { baiduAnalyticsPlugin } from '@vuepress/plugin-baidu-analytics'

export default {
  plugins: [
    baiduAnalyticsPlugin({
      // options
    }),
  ],
}

Event Tracking

Once configured, the plugin will automatically report page view (PV) events for both initial page loads and subsequent route navigations.

For advanced usage, the global _hmt array is exposed on the window object. You can utilize this to push custom events manually.

// Example: Manually reporting a custom event
window._hmt = window._hmt || []
window._hmt.push(['_trackEvent', 'category', 'action', 'label', 'value'])

Options

id

  • Type: string
  • Required: Yes
  • Details: The tracking ID for your Baidu Analytics account. This is usually the string found in the hm.js script URL provided by Baidu (e.g., hm.js?your_tracking_id).
Edit this page on GitHub
Last Updated: 11/29/25, 4:17 AM
Contributors: Mister-Hope, Zihan Hu
Next
clarity-analytics