2012-07-03 207 views
0

這裏是我使用的腳本,直接從谷歌複製:自定義事件沒有被跟蹤在谷歌Analytics(分析)

<script type="text/javascript"> 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-CODE']); 
    _gaq.push(['_trackPageview']); 

    (function() { 
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
    })(); 

    function recordOutboundLink(link, category, action) { 
     try { 
      var myTracker=_gat._getTrackerByName(); 
      _gaq.push(['myTracker._trackEvent', category , action ]); 
      setTimeout('document.location = "' + link.href + '"', 100); 
     }catch(err){} 
    } 
</script> 

,這裏是鏈接我試圖追蹤:

<a href="http://www.website.com/" target="_blank" class="ad" onClick="recordOutboundLink(this, 'Outbound Links', 'Visited website.com');return false;"></a> 

但在過去3天的活動報告中並沒有出現任何內容。我的代碼有問題嗎?

回答

1

有與Google's Outbound links tracking example

你只使用一個跟蹤器(它看起來像你的代碼)假設的問題,下面的工作:

function recordOutboundLink(link, category, action) { 
    try { 
     _gaq.push(['_trackEvent', category , action ]); 
     setTimeout('document.location = "' + link.href + '"', 100); 
    }catch(err){} 
} 
相關問題