Google Analytics事件跟踪代码无效

时间:2011-03-29 01:42:23

标签: php javascript google-analytics analytics

我正在使用Google Analytics异步跟踪代码,并尝试跟踪this download page上“下载”按钮的点击次数。 (通常通过其父页面quitnowri.com通过Shadowbox访问。)

有一次,事件跟踪工作正常 - 我能够在报告中跟踪一个下载事件。

但后来,我更改了“下载”按钮,强制通过php下载this method

standard event tracking JavaScript onClick handler无效(已在said download page上注释掉),因此我在跟踪事件时尝试使用Google Analytics中的功能delay pageload。这在5天之后都没有用。

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

FIREBUG

FIREBUG DUDE!

答案 1 :(得分:1)

未定义的JavaScript变量确实存在问题。解决方案是。

头脑中:

<script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXXXXX-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>
    <!-- delay to ensure that events are tracked http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527-->
    <script type="text/javascript">
      function recordOutboundLink(link, trackEvent, category, action) {
        _gat._getTrackerByName()._trackEvent(trackEvent, category, action);
        setTimeout('document.location = "' + link.href + '"', 100);
      }
    </script>
<script type="text/javascript">
      function recordOutboundLink(link, trackEvent, category, action) {
        _gat._getTrackerByName()._trackEvent(trackEvent, category, action);
        setTimeout('document.location = "' + link.href + '"', 100);
      }
</script>

在链接上:

<a href="download.php" id="download" class="download" name="Constant Reminder Ringtone" onClick="recordOutboundLink(this, 'Files', 'Download', 'Constant Reminder Ringtone');return false;">DOWNLOAD</a>