Home

Awesome

<p align="center"> <img src="https://i.imgur.com/iu7VdZ7.png" /> <br> <br> <a href="https://badge.fury.io/js/vue-yandex-metrika"> <img src="https://badge.fury.io/js/vue-yandex-metrika.svg" /> </a> <a href="https://www.npmjs.com/package/vue-yandex-metrika"> <img src="https://img.shields.io/npm/dm/vue-yandex-metrika.svg" /> </a> <br> <a href="https://travis-ci.org/vchaptsev/vue-yandex-metrika"> <img src="https://travis-ci.org/vchaptsev/vue-yandex-metrika.svg?branch=master" /> </a> <a href='https://coveralls.io/github/vchaptsev/vue-yandex-metrika?branch=master'> <img src='https://coveralls.io/repos/github/vchaptsev/vue-yandex-metrika/badge.svg?branch=master' /> </a> </p>

Vue Yandex Metrika

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

Installation

Install with yarn:

$ yarn add vue-yandex-metrika

Install with npm:

$ npm install vue-yandex-metrika --save

Ways to use

<a name="autotracking">Autotracking</a>

Pass the VueRouter 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
})

<a name="manual">Manual tracking</a>

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
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}