Skip to content

vchaptsev/vue-yandex-metrika

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



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

Usage

Pass the VueRouter instance to the plugin and let it handle everything for you:

// 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
    // other options
})

Options:

Name Description Required Default
id Your tracking id True null
router VueRouter object True null
env "production" or "development" False process.env.NODE_ENV || "production"
onlyProd Do not track a page visit if env !== "production" False true
ignoreRoutes List of ignored routes names False []
skipSamePath Do not track a page visit if previous and next routes URLs match False false

You are also able to use Metrika API wherever you want to:

this.$metrika.hit('path')