react-yandex-metrika
react-yandex-metrika copied to clipboard
Doesn't work api method - getClientID
Hello.
Yandex Metrika has method getClientID
. This method return some value.
yaCounterXXXXXX.getClientID() // id
But i can't take this value in ym:
ym('getClientID') // undefined
https://yandex.ru/support/metrika/objects/get-client-id.html
Well, ym is written with fire-and-forget use case in mind, so apparently it won't work. I would suggest two possible solutions:
- if you're sure that the counter is ready by the time you're going to call
getClientID
, then just usewindow['yaCounterXXXXXX'].getClientID()
, it's there; - otherwise,
ym
could probably rely ontriggerEvent
parameter and return a promise.