vue-y-metrika

0.0.2 • Public • Published




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:

Name Description Required Default
id Your tracking id True null
router Autotracking if the router is passed, otherwise: manual tracking False null
env API calls are performed only if env is "production" False development
scriptSrc Src of metrika script to use False https://mc.yandex.ru/metrika/tag.js
debug If env is not "production" and debug is true: API calls are replaced by console.log() False false
ignoreRoutes List of ignored routes names False []
skipSamePath Do not track a page visit if previous and next routes URLs match False true
options Original Yandex Metrika options False {clickmap:true, trackLinks:true, accurateTrackBounce:true}

Package Sidebar

Install

npm i vue-y-metrika

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

11.3 kB

Total Files

4

Last publish

Collaborators

  • geekfil