Answer the question
In order to leave comments, you need to log in
How to disable yandex metric in nuxt if env != prod?
Hello!
I use the @nuxtjs/yandex-metrika plugin, but I can’t find something how to disable the metric depending on the environment
In general, you need to disable it if APP_ENVIRONMEN != prod
Now I’m just trying not to pass the metric id, but this is wrong
// в nuxt.config
modules: [
[
'@nuxtjs/yandex-metrika',
{
id: (process.env.APP_ENVIRONMENT as string) === 'prod' ? '8******' : '',
webvisor: true,
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
}
]
],
Answer the question
In order to leave comments, you need to log in
Check with your DNS provider to see if you can set up a 301 redirect.
If hosting is ordered:
1. Go to the control panel
2. Web server
3. Sites
4. Select the desired site
5. Site management -> "Site mode" -> "Redirect"
The modules array can be built up to the object in which it will be used.
Below is an example.
const module = ['@nuxt/recaptcha']
if ((process.env.APP_ENVIRONMENT as string) === 'prod') {
modules.push([
'@nuxtjs/yandex-metrika',
{
id: '8******',
webvisor: true,
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
}
])
}
export default {
...
modules,
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question