0.0.3 • Published 2 years ago

vue-yandex-metrika-v3 v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vue 3 Yandex Metrika

vue-yandex-metrika-v3 allows you to send data about visited pages to Yandex Metrika.

Installation

Install with yarn:

$ yarn add vue-yandex-metrika-v3

Install with npm:

$ npm install vue-yandex-metrika-v3 --save

Ways to use

Autotracking

Pass theVueRouter 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 VueYandexMetrika from 'vue-yandex-metrika-v3'                               

const router = createRouter({...}) // your routes

const app = createApp(App)

app.use(router)
app.use(VueYandexMetrika, {
	id: XXXXXXXX,
	router: router,
	env: process.env.NODE_ENV
    // other options
})

app.mount( '#app')

Manual tracking

Works without router: Metrika API

// your main.js
import { createApp } from 'vue'
import VueYandexMetrika from 'vue-yandex-metrika-v3'

app.use(VueYandexMetrika, {
    id: XXXXXXXX,
    env: process.env.NODE_ENV
    // other options
})

// with Options API
// your code
this.$metrika.hit(path)

Options:

NameDescriptionRequiredDefault
idYour tracking idTruenull
routerAutotracking if the router is passed, otherwise: manual trackingFalsenull
envAPI calls are performed only if env is "production"Falsedevelopment
scriptSrcSrc of metrika script to useFalsehttps://mc.yandex.ru/metrika/tag.js
debugIf env is not "production" and debug is true: API calls are replaced by console.log()Falsefalse
ignoreRoutesList of ignored routes namesFalse[]
skipSamePathDo not track a page visit if previous and next routes URLs matchFalsetrue
optionsOriginal Yandex Metrika optionsFalse{clickmap:true, trackLinks:true, accurateTrackBounce:true}