简体   繁体   English

Google Analytics(分析)事件跟踪不起作用

[英]Google analytics event tracking not working

I have this code setup to track image downloads throught Google Analytics. 我有此代码设置来跟踪Google Analytics(分析)中的图片下载。

<a href="/media/37768/CC20100117m001_thumb_2000.jpg"
    onclick="pageTracker._trackEvent('Image', 'Download', 'file.jpg');" 
    class="hi-res track">
Hi-Res</a>

But the events don't ever show up in the GA reports. 但是这些事件永远不会出现在GA报告中。

I thought maybe the the browser was following the link before the javascript was being run but setting href="#" doesn't work either. 我以为可能浏览器在运行javascript之前就已经跟随了链接,但是设置href =“#”也不起作用。

Any ideas? 有任何想法吗?

Your browser may be following the link before Analytics can make the call logging the event. 在Analytics(分析)可以拨打电话记录事件之前,您的浏览器可能会跟踪该链接。 Check out this page for Google's solution: 查看此页面以了解Google的解决方案:
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527 http://www.google.com/support/googleanalytics/bin/answer.py?hl=zh_CN&answer=55527

I faced a lot of problem then I realize it's easy steps and want to share with everyone. 我遇到了很多问题,然后我意识到这是简单的步骤,想与大家分享。 First change your script code, link is https://developers.google.com/analytics/devguides/collection/gajs/#quickstart 首先更改您的脚本代码,链接为https://developers.google.com/analytics/devguides/collection/gajs/#quickstart

Second add a button like this. 第二,添加一个像这样的按钮。
<>button onclick="_gaq.push(['_trackEvent', 'button3', 'clicked'])">Press<>/button> <> button onclick =“ _ gaq.push(['_ trackEvent','button3','clicked']))”>按<> / button>

Enjoy :) 请享用 :)

I don't know what your error is but to find out what it is you can: 我不知道您的错误是什么,但可以找出错误所在:

  • Install firefox 安装Firefox
  • Click on the link 点击链接
  • Go to Tools | 转到工具| Error Console 错误控制台
  • Look at the error 看一下错误

This doesn't look correct to me--for one thing, you're using 'pageTracker' to call _trackEvent. 这对我来说似乎不正确-一方面,您正在使用“ pageTracker”调用_trackEvent。 In fact, _trackEvent is called by an 'event tracker' object, which is instantiated with _createEventTracker. 实际上,_trackEvent由“事件跟踪器”对象调用,该对象用_createEventTracker实例化。

There are a couple more steps you haven't mentioned so et's go through them all. 您还没有提到其他几个步骤,因此请遍历所有步骤。 (There could be more than one correct way to do this--i'm not sure. So what i can do is compare your code with the steps i follow every time i set up Event Tracking, and which so far, have worked every time.) (执行此操作可能有不止一种正确的方法-我不确定。因此,我可以做的是将您的代码与我每次设置事件跟踪时所遵循的步骤进行比较,到目前为止,每种方法都有效时间。)

  1. Enable 'Event Tracking' . 启用“事件跟踪” (Do this in your profile.) (在您的个人资料中执行此操作。)

  2. Create the 'event tracker' instance and insert it just after the last line of the pageTracker script. 创建“事件跟踪程序”实例 ,并将其插入到pageTracker脚本的最后一行之后。 This is usually a single line of code that in your case would look something like this: 这通常是单行代码,在您的情况下看起来像这样:

     var ImageTracker = pageTracker._createEventTracker("Image") 
  3. Set up the call to the _trackEvent() method in your html . 在html中设置对_trackEvent()方法的调用 I think all you need to do here is replace 'pageTracker' in your code with 'ImageTracker' (the event tracker instance you created in step 2 above). 我认为您所需要做的就是将代码中的“ pageTracker”替换为“ ImageTracker”(您在上述第2步中创建的事件跟踪器实例)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM