Vue Yandex Metrika is a utility package designed to integrate Yandex Metrika tracking into Vue.js applications. It simplifies the process of sending page view data to Yandex Metrika, offering both automatic tracking when integrated with Vue Router and manual tracking capabilities. The current stable version is v1.8.3, released in September 2019, indicating a lack of active development since then. Its primary differentiator is its direct integration with the Vue ecosystem, abstracting the raw Yandex Metrika API calls. It allows configuration of tracking ID, environment-based tracking (e.g., only in production), script source, debug mode, route ignoring, and other Yandex Metrika counter options, providing a convenient wrapper for web analytics in Vue projects. Given its last update in 2019, it primarily supports older Vue 2 applications and may not be compatible with Vue 3 without community efforts or significant adaptations.
npm install vue-yandex-metrikaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the automatic page view tracking with Vue Router, configuring Yandex Metrika with a placeholder ID, environment-specific settings, debug mode, and additional Metrika options.
Update any calls from `this.$metrika.userParam()` to `this.$metrika.userParams()`.
For testing in non-production environments, set `debug: true` in your Vue.use() options: `Vue.use(VueYandexMetrika, { ..., env: process.env.NODE_ENV, debug: true })`.If targeting Vue 3, consider using an alternative, or be prepared to fork and update the package for Vue 3 compatibility. For Vue 2, proceed with caution regarding potential unpatched bugs or security vulnerabilities.
If you need to track repeated visits to the same URL, set `skipSamePath: false` in the plugin options: `Vue.use(VueYandexMetrika, { ..., skipSamePath: false })`.Ensure `Vue.use(VueYandexMetrika, { ... })` is called at the application's entry point before any component tries to access `this.$metrika`.Provide a valid Yandex Metrika counter ID in the plugin options: `Vue.use(VueYandexMetrika, { id: 'YOUR_COUNTER_ID', ... })`.Ensure `import Vue from 'vue'` is present at the top of your main JavaScript file where the plugin is being installed.