Google Analytics hitCallback event tracking not working

后端 未结 1 1380
说谎
说谎 2021-01-12 19:20

I am trying to track a link being clicked using event tracking and hitcallback. My analytics code looks like this...



        
相关标签:
1条回答
  • 2021-01-12 19:42

    The problem is you are attempting to use Universal Analytics syntax (analytics.js) for your click tracking, but the GA library you are using is the older _gaq (ga.js) syntax.

    _gaq style does let you specify a callback function, though it's undocumented. Basically you have to _set the callback function before you make the _trackEvent call.

    Your link should look like this:

    <a href='http://cool.com' onclick="var _this=this;_gaq.push(['_set','hitCallback',function(){document.location=_this.href;}]);_gaq.push(['_trackEvent','outbound','click',_this.href]);return false;">cool</a>
    
    0 讨论(0)
提交回复
热议问题