JSPM

vue3-yandex-metrika

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 635
  • Score
    100M100P100Q105094F
  • License MIT

Yandex Metrika plugin for Vue3

Package Exports

  • vue3-yandex-metrika
  • vue3-yandex-metrika/dist/vue3-yandex-metrika.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue3-yandex-metrika) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Vue v3 Yandex Metrika

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

Installation

Install with yarn:

$ yarn add vue3-yandex-metrika

Install with npm:

$ npm install vue3-yandex-metrika --save

Ways to use

Autotracking

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

// your main.js
import { createApp } from 'vue'
import { createRouter } from "vue-router";
import VueYandexMetrika from 'vue3-yandex-metrika'                               

const router = createRouter({...}) // your routes

const app = createApp(App)

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

app.mount( '#app')

Manual tracking

Works without router: Metrika API

// your main.js
import { createApp } from 'vue'
import VueYandexMetrika from 'vue3-yandex-metrika'                               

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

// your code
this.$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}