0.0.2 • Published 4 years ago

vue-y-metrika v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Vue Yandex Metrika

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

Installation

Install with yarn:

$ yarn add vue-y-metrika

Install with npm:

$ npm install vue-y-metrika --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 Vue from 'vue'
import VueRouter from 'vue-router'
import VueYandexMetrika from 'vue-y-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-y-metrika'                               

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

// example call method
this.$metrika.hit(path)
// example call method after load script
{
    mounted(){
        this.$metrikaEvents.$on('ym:ready',function(metrika) {
         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}