npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-yandex-metrika-ts

v2.0.0

Published

Vue plugin for Yandex Metrika with TypeScript support

Readme

npm version npm downloads NPM license npm type definitions CI donate GitHub Repo stars

Vue Yandex Metrika Plugin with TypeScript

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

Installation

Install with yarn:

$ yarn add vue-yandex-metrika-ts

Install with npm:

$ npm install vue-yandex-metrika-ts --save

Ways to use

Vue 2

Root import is Vue 2 compatible (same as v1.x):

import Vue from 'vue'
import VueRouter from 'vue-router'
import VueYandexMetrika from 'vue-yandex-metrika-ts'

const router = new VueRouter({...})

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

Explicit Vue 2 subpath (optional):

import VueYandexMetrika from 'vue-yandex-metrika-ts/vue2'

Vue 3

import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import VueYandexMetrika from 'vue-yandex-metrika-ts/vue3'

const app = createApp(App)
const router = createRouter({ history: createWebHistory(), routes: [] })

app.use(router)
app.use(VueYandexMetrika, {
  id: XXXXXXXX,
  router,
  env: import.meta.env.MODE,
})

app.mount('#app')
import { useMetrika } from 'vue-yandex-metrika-ts/vue3'

// in <script setup>
const metrika = useMetrika()
metrika.reachGoal('SIGNUP')

Helpers API

import {
  loadMetrikaScript,
  createMetrika,
  startTracking,
} from 'vue-yandex-metrika-ts/helpers'

Autotracking

Pass the VueRouter instance to the plugin and let it handle everything for you (Metrika API is also available):

// Vue 2
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueYandexMetrika from 'vue-yandex-metrika-ts'

const router = new VueRouter({...})

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

Manual tracking

Works without router. Full Metrika API is available on $metrika / getCurrentInstance()?.appContext.config.globalProperties.$metrika.

Vue.use(VueYandexMetrika, {
  id: XXXXXXXX,
  env: 'production',
  options: {
    // initial visit/visitor params
    params: { section: 'landing' },
    userParams: { UserID: 42 },
    // defer: true — disable auto pageview; call hit() manually on start
    // trackHash: true — track hash changes without vue-router
  },
})
// page view with visit params
this.$metrika.hit('/checkout', {
  title: document.title,
  referer: '/cart',
  params: {
    order_price: 1990,
    currency: 'RUB',
    step: 'payment',
  },
})

// current URL (url is optional — defaults to window.location.href)
this.$metrika.hit()

// goals, visit and visitor params
this.$metrika.reachGoal('ORDER', { order_price: 1990, currency: 'RUB' })
this.$metrika.params({ event: 'filter', value: 'price' })
this.$metrika.userParams({ plan: 'pro' })

// advanced matching (HTTPS only)
this.$metrika.firstPartyParams({
  email: '[email protected]',
  phone_number: '79001234567',
})

Autotracking with router sends only hit(path, { referer }). Use manual hit() when you need title, params, or other fields.

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

Peer dependencies

  • vue ^2.6.0 || ^3.0.0 (required)
  • vue-router ^3.0.0 || ^4.0.0 || ^5.0.0 (optional, only for autotracking)