Custom Tracking with Google Analytics

强颜欢笑 提交于 2020-01-14 03:28:08

问题


I am trying to figure out how to use my google analytics account, and do custom tracking on certain links and such, but following the technical information on the help site on google isn't getting me anywhere. Has anyone done something like this? Point me in the right direction.

UPDATE This is the code, I am not seeing the results in my analytics account yet, but I am not getting errors now.

In header:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX']); //Commented Out for posting
  _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';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();

</script>

THen on the href of my link I put this:

onclick="_gaq.push(['_trackEvent', 'Link Sponsored', 'Clicked Sponsored']);"

Is this the Correct Way to do it via asyc ga code?


回答1:


I can't find the problem from your code.

A couple of things:

  1. have you enabled "Event Tracking"? This must be set in your "Profile"

  2. While watching HTTP header activity using, for instance, the Firefox add-on "Live HTTP Headers", look for requests to the _utm.gif. To do this:

    • open the LiveHTTP Headers Panel;

    • then select the "Config" tab;

    • then check "Filter URLs with regexp;

    • type _utm.gif in the text box next to the box you just chekecked; and

    • select the "Generator" tab to record the activity.



来源:https://stackoverflow.com/questions/2403601/custom-tracking-with-google-analytics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!