Note
This repository is archived. @nuxtjs/yandex-metrika was built for Nuxt 2, which reached end of life on June 30, 2024.
Warning
Yandex Metrika is known for Security and Privacy issues. Please Read More Here.
This plugin automatically sends first page and route change events to yandex metrika.
- Add
@nuxtjs/yandex-metrikadependency using yarn or npm to your project - Add
@nuxtjs/yandex-metrikatomodulessection ofnuxt.config.js
{
modules: ['@nuxtjs/yandex-metrika'],
}You can pass options directly in module declaration:
{
modules: [
[
'@nuxtjs/yandex-metrika',
{
id: 'XXXXXX',
webvisor: true,
// clickmap: true,
// useCDN: false,
// trackLinks: true,
// accurateTrackBounce: true,
}
]
]
}Or you can specify yandexMetrika key:
{
modules: ['@nuxtjs/yandex-metrika'],
yandexMetrika: {
id: 'XXXXXX',
// ...
}
}In Nuxt 2.13+, you can also use public runtime config:
{
modules: ['@nuxtjs/yandex-metrika'],
publicRuntimeConfig: {
yandexMetrika: {
id: process.env.YANDEX_METRIKA_ID,
// ...
}
}
}For more information:
- Required
- Default:
yandexMetrika
Public runtime config key. Set to false to disable runtime configuration.
- Default: false
Load metrika script from https://cdn.jsdelivr.net/npm/yandex-metrica-watch/watch.js.
This option can not be provided via runtime config.