Shoora
3/31/2019 - 5:12 PM

Yandex metrix. Universal way for working with goals

Yandex metrix. Universal way for working with goals

function yaCounterObject(){
  var yaCounterKey = Object.keys(window).find( function(el, ind, ar){
    return el.search('yaCounter') >= 0 ? true : false ;
  })
  console.log('yaCounterKey', yaCounterKey)
  var yaCounterObject = window[yaCounterKey]
  // console.log('yaCounterObject',yaCounterObject)
  return yaCounterObject
}

var yandexCounter = yaCounterObject()
yandexCounter.reachGoal('headTelLink')