yandex-metrika-vue3
**yandex-metrika-vue3** allows you to send data about visited pages to [Yandex Metrika]. Installation Install with [yarn]: Install with [npm]: Ways to us
89,962
11
| Install | |
|---|---|
npm install yandex-metrika-vue3 |
|
| Latest Version: | 1.3.4 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jan 24, 2025 |
| Links: | GitHub · npm |
Maintainer: kennardys
Vue Yandex Metrika Plugin with TypeScript
yandex-metrika-vue3 allows you to send data about visited pages to Yandex Metrika.
Installation
Install with yarn:
$ yarn add yandex-metrika-vue3
Install with npm:
$ npm install yandex-metrika-vue3 --save
Ways to use
Autotracking
Pass the VueRouter instance to the plugin and let it handle everything for you (Metrika API is also available):
// your main.js
import { createApp } from 'vue';
import { createRouter } from "vue-router";
import { initYandexMetrika } from 'yandex-metrika-vue3';
const router = new VueRouter({...}) // your routes
const app = createApp(App)
app.use(initYandexMetrika, {
id: XXXXXXXX,
router: router,
env: process.env.NODE_ENV
// other options
})
Manual tracking
Works without router: Metrika API
// your main.js
import { createApp } from 'vue';
import { initYandexMetrika } from 'yandex-metrika-vue3';
const app = createApp(App)
app.use(initYandexMetrika, {
id: XXXXXXXX,
env: process.env.NODE_ENV,
// other options
});
Using in template
<template>
<button @click="$yandexMetrika.hit(path)"></button>
</template>
Using in script
<script setup>
import { useYandexMetrika } from 'yandex-metrika-vue3'
const yandexMetrika = useYandexMetrika()
const foo = () => {
yandexMetrika.hit(path)
}
</script>
Options
/* If you want to override the default options,
* then add this to the initialization function in main.js
*/
// default options
options: {
accurateTrackBounce: true,
clickmap: true,
defer: false,
ecommerce: false,
params: [],
userParams: {},
trackHash: false,
trackLinks: true,
type: 0,
webvisor: false,
triggerEvent: false
},
Related Packages
@rkaliev/nuxt-yandex-metrika
Модуль Nuxt 4 для Яндекс Метрики (Nuxt 4 module for Yandex Metrika)
1,921
20
Version History
| Version | Released | License |
|---|---|---|
| 1.3.4 | MIT | |
| 1.3.3 | MIT | |
| 1.3.2 | MIT | |
| 1.3.1 | MIT | |
| 1.3.0 | MIT | |
| 1.2.2 | MIT | |
| 1.2.1 | MIT | |
| 1.2.0 | MIT | |
| 1.1.7 | MIT | |
| 1.1.6 | MIT | |
| 1.1.5 | MIT | |
| 1.1.4 | MIT | |
| 1.1.3 | MIT | |
| 1.1.2 | MIT | |
| 1.1.1 | MIT | |
| 1.1.0 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT |
Pre-releases (2)
| Version | Released | License |
|---|---|---|
| 1.3.0-beta.2 | MIT | |
| 1.3.0-beta.1 | MIT |