react-yandex-metrika icon indicating copy to clipboard operation
react-yandex-metrika copied to clipboard

Doesn't work api method - getClientID

Open bratva opened this issue 7 years ago • 1 comments

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

bratva avatar Dec 27 '17 10:12 bratva

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 use window['yaCounterXXXXXX'].getClientID(), it's there;
  • otherwise, ym could probably rely on triggerEvent parameter and return a promise.

narkq avatar Dec 27 '17 17:12 narkq