我正在尝试使用谷歌分析来计算网页上某些元素的点击次数,这是我的新手。我昨天设置了它,这是我的代码:
放置在结束</head>
标记之前(根据此处的说明),我有这个:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33903909-1']);
_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>
</head>
我还有一组元素:
<div class="block aside" id ="slideAside">
<aside>
<form class="form">
<fieldset id="fs_section_abstract" class="fs section abstract">
<label id="fs_abstract_heading" class="fs btn heading abstract">Abstract</label>
</fieldset>
<fieldset id="fs_section_businessapproach" class="fs section businessapproach">
<label id="fs_businessapproach_heading" class="fs btn heading businessapproach">Business Approach</label>
</fieldset>
<fieldset id="fs_section_workexperience" class="fs section workexperience">
<label id="fs_workexperience_heading" class="fs btn heading workexperience">Work Experience</label><br>
</fieldset>
<fieldset id="fs_section_academic" class="fs section academic">
<label id="fs_academic_heading" class="fs btn heading academic">Academic</label>
</fieldset>
<fieldset id="fs_section_skillstable" class="fs section skillstable">
<label id="fs_skillstable_heading" class="fs btn heading skillstable">Skills Table</label><br>
</fieldset>
<fieldset id="fs_section_community" class="fs section community">
<label id="fs_community_heading" class="fs btn heading community">Community</label><br>
</fieldset>
</form>
</aside>
</div>
为了跟踪它们,在下面的脚本中,我有:
$('.btn').click(function () {
//FS IDentifier
if ($(this).hasClass("fs")) {
//heading
if ($(this).hasClass("heading")) {
//track number of times clicked
_gaq.push(['_trackEvent', 'Heading', 'The ID is' + $(this).attr('id') + '.']);
_gaq.push(['_trackEvent', 'Heading', 'HEading']);
我已经设置了将近一天的 GA Analytics,并尝试了上述两个_gaq.push()
es 以及其他几种方法,但是在分析页面的“内容”部分的“事件”部分没有注册。
我是不是误会了什么?我的代码不好吗?
我知道这是异步跟踪,但结果是每天更新还是其他时间间隔更新?如果是每天,同步更新需要付费吗?