1.0.2 • Published 2 years ago

@blackwall/vue-yandex-metrika v1.0.2

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
2 years ago

@bchteam/vue-yandex-metrika

@bchteam/vue-yandex-metrika allows you to send data about visited pages to Yandex Metrika.

Installation

Install with npm:

$ npm i -S @bchteam/vue-yandex-metrika

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 Vue from 'vue'
import VueRouter from 'vue-router'
import VueYandexMetrika from 'vue-yandex-metrika'                               

const router = new VueRouter({...}) // your routes

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

Manual tracking

Works without router: Metrika API

// your main.js
import Vue from 'vue'
import VueYandexMetrika from 'vue-yandex-metrika'                               

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

// 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
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
onInit(metrika, config)Function called when Yandex metrika loaded and ready to use. Passed 'config' is final used configFalsenull
onFail(error)Function called when error occurred during loading Yandex Metrika script or its initialization.Falsenull
optionsOriginal Yandex Metrika optionsFalse{clickmap:true, trackLinks:true, accurateTrackBounce:true}
1.0.2

2 years ago