-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$metrika is undefined #10
Comments
You probably have a race condition. You think that the prototype $metrika is already available but it is not. You can check that by adding this to your URL:
If the error occurs before "PageView. Counter XXXXXXXX . URL: ............" you have a race condition problem. I'm using the reachGoal function in a action (Vuex) and I have the same issue. You could use a try and catch block. |
I am experiencing the same issue
which is not desirable solution |
Setting everywhere a timeout is not a great solution. Especially when the DOM is still not rendered after 2 seconds for whatever reason (theoretically). After some reasearch and reading the Vue.js documentation, I came to the solution that you have to use the mounted and the $nextTick function in combination to be sure that the DOM is fully rendered (and so the Yandex Metrika script):
Source: Vue.js documentation Just implement their example:
After some tests, it seems that my try-and-catch-block is not triggered anymore. It works and it is a cleaner solution than a timer. Hopefully I could help :) |
@picarsite yes $nextTick is a common way to ensure the Vue's DOM operations are done, but if we look deeper into YM docs - we could try to achieve this with:
|
...
Then use @shershen08 solution in your component
|
I faced with same problem. If user enable AdBlock or other script remover, i can't call reachGoal(). I get error. I solved this problem with try-catch. Now, it's work perfect.
Call in your code: |
Add $metrikaEvents:
Listen
|
fixed and updated. it works! |
Had same issue in Firefox private tab. Add check before submit goal if
|
Tried much options, but UPDATE @armbull Works with |
Hey.
vue-yandex-metrika
version: 1.7.2node
version: 10.13.0npm
(oryarn
) version: 6.4.1Relevant code or config
Problem description:
After call method handleImport():
https://sentry.io/share/issue/9c0025640c52451baaf56572326847bf/
The text was updated successfully, but these errors were encountered: