我在使用 Google Analytics 时遇到了问题,即无法在“行为” > “事件” > “热门事件”下找到计数数据。
我正在使用经典分析。这是我的代码:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_setDomainName', 'domain.com']);
_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);
})();
</script>
<script>
// custom events:
$(function() {
$('button').each(function(){
$(this).html($(this).data('event'));
});
$('button').click(function(){
var event = $(this).data('event');
_gaq.push(['_trackEvent', 'USER_INTERACTION', event, 'whatever babe']);
console.log(event);
});
});
</script>
<button type="button" data-event="CLICKS_BUTTON_1"></button><br />
<button type="button" data-event="CLICKS_BUTTON_2"></button><br />
<button type="button" data-event="CLICKS_BUTTON_3"></button><br />
<button type="button" data-event="CLICKS_BUTTON_4"></button><br />
<button type="button" data-event="CLICKS_BUTTON_5"></button><br />
<button type="button" data-event="CLICKS_BUTTON_6"></button><br />
<button type="button" data-event="CLICKS_BUTTON_7"></button><br />
<button type="button" data-event="CLICKS_BUTTON_8"></button><br />
<button type="button" data-event="CLICKS_BUTTON_9"></button><br />
<button type="button" data-event="CLICKS_BUTTON_10"></button><br />
<button type="button" data-event="CLICKS_BUTTON_11"></button><br />
<button type="button" data-event="CLICKS_BUTTON_12"></button><br />
<button type="button" data-event="CLICKS_BUTTON_13"></button><br />
<button type="button" data-event="CLICKS_BUTTON_14"></button><br />
<button type="button" data-event="CLICKS_BUTTON_15"></button><br />
然而,在实时部分下,事件跟踪数据出现了且正常。是否还有其他必要的事情(代码)需要实施,以便它出现在行为> 事件部分?