Add Yandex Metrika to your nuxt.js application.
This plugins automatically sends first page and route change events to yandex metrika.
Note: yandex metrika is not enabled in dev mode.
You can set environment variable NODE_ENV
to production
for testing in dev mode.
- Add
@ruvents/yandex-metrika
dependency using yarn or npm to your project - Add
@ruvents/yandex-metrika
tomodules
section ofnuxt.config.js
{
modules: ['@ruvents/yandex-metrika'],
}
You can pass options directly in module declaration:
{
modules: [
[
'@ruvents/yandex-metrika',
{
id: 'XXXXXX',
webvisor: true,
// clickmap: true,
// useCDN: false,
// trackLinks: true,
// accurateTrackBounce: true,
}
]
]
}
Or you can specify yandexMetrika
key:
{
modules: ['@ruvents/yandex-metrika'],
yandexMetrika: {
id: 'XXXXXX',
// ...
}
}
In Nuxt 2.13+, you can also use public runtime config:
{
modules: ['@ruvents/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.
- Default:
undefined
Array of keys which must be excluded in queries.